Spaces:
Running
Running
Jeremiah Lowin commited on
Update agents.md; add github instructinos (#1410)
Browse files- .github/copilot-instructions.md +1 -0
- AGENTS.md +58 -7
.github/copilot-instructions.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
../AGENTS.md
|
AGENTS.md
CHANGED
|
@@ -1,13 +1,21 @@
|
|
| 1 |
# FastMCP Development Guidelines
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
## Required Development Workflow
|
| 4 |
|
|
|
|
|
|
|
| 5 |
```bash
|
| 6 |
uv sync # Install dependencies
|
| 7 |
uv run pre-commit run --all-files # Ruff + Prettier + Pyright
|
| 8 |
uv run pytest # Run full test suite
|
| 9 |
```
|
| 10 |
|
|
|
|
|
|
|
| 11 |
**Tests must pass and lint/typing must be clean before committing.**
|
| 12 |
|
| 13 |
## Repository Structure
|
|
@@ -15,14 +23,21 @@ uv run pytest # Run full test suite
|
|
| 15 |
| Path | Purpose |
|
| 16 |
| ---------------- | ------------------------------------------------------ |
|
| 17 |
| `src/fastmcp/` | Library source code (Python ≥ 3.10) |
|
| 18 |
-
| `
|
| 19 |
-
| `
|
| 20 |
-
| ` └─
|
| 21 |
-
| `
|
| 22 |
-
| ` └─
|
| 23 |
-
| `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
| `docs/` | Mintlify documentation (published to gofastmcp.com) |
|
| 25 |
-
| `examples/` |
|
| 26 |
|
| 27 |
## Core MCP Objects
|
| 28 |
|
|
@@ -81,3 +96,39 @@ async with Client(transport=StreamableHttpTransport(server_url)) as client:
|
|
| 81 |
- Uses Mintlify framework
|
| 82 |
- Files must be in docs.json to be included
|
| 83 |
- Never modify `docs/python-sdk/**` (auto-generated)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# FastMCP Development Guidelines
|
| 2 |
|
| 3 |
+
> **Audience**: LLM-driven engineering agents and human developers
|
| 4 |
+
|
| 5 |
+
FastMCP is a comprehensive Python framework (Python ≥3.10) for building Model Context Protocol (MCP) servers and clients. This is the actively maintained v2.0 providing a complete toolkit for the MCP ecosystem.
|
| 6 |
+
|
| 7 |
## Required Development Workflow
|
| 8 |
|
| 9 |
+
**CRITICAL**: Always run these commands in sequence before committing:
|
| 10 |
+
|
| 11 |
```bash
|
| 12 |
uv sync # Install dependencies
|
| 13 |
uv run pre-commit run --all-files # Ruff + Prettier + Pyright
|
| 14 |
uv run pytest # Run full test suite
|
| 15 |
```
|
| 16 |
|
| 17 |
+
**All three must pass** - this is enforced by CI. Alternative: `just build && just typecheck && just test`
|
| 18 |
+
|
| 19 |
**Tests must pass and lint/typing must be clean before committing.**
|
| 20 |
|
| 21 |
## Repository Structure
|
|
|
|
| 23 |
| Path | Purpose |
|
| 24 |
| ---------------- | ------------------------------------------------------ |
|
| 25 |
| `src/fastmcp/` | Library source code (Python ≥ 3.10) |
|
| 26 |
+
| ` ├─server/` | Server implementation, `FastMCP`, auth, networking |
|
| 27 |
+
| ` │ ├─auth/` | Authentication providers (Bearer, JWT, WorkOS) |
|
| 28 |
+
| ` │ └─middleware/` | Error handling, logging, rate limiting |
|
| 29 |
+
| ` ├─client/` | High-level client SDK + transports |
|
| 30 |
+
| ` │ └─auth/` | Client authentication (Bearer, OAuth) |
|
| 31 |
+
| ` ├─tools/` | Tool implementations + `ToolManager` |
|
| 32 |
+
| ` ├─resources/` | Resources, templates + `ResourceManager` |
|
| 33 |
+
| ` ├─prompts/` | Prompt templates + `PromptManager` |
|
| 34 |
+
| ` ├─cli/` | FastMCP CLI commands (`run`, `dev`, `install`) |
|
| 35 |
+
| ` ├─contrib/` | Community contributions (bulk caller, mixins) |
|
| 36 |
+
| ` ├─experimental/` | Experimental features (new OpenAPI parser) |
|
| 37 |
+
| ` └─utilities/` | Shared utilities (logging, JSON schema, HTTP) |
|
| 38 |
+
| `tests/` | Comprehensive pytest suite with markers |
|
| 39 |
| `docs/` | Mintlify documentation (published to gofastmcp.com) |
|
| 40 |
+
| `examples/` | Runnable demo servers (echo, smart_home, atproto) |
|
| 41 |
|
| 42 |
## Core MCP Objects
|
| 43 |
|
|
|
|
| 96 |
- Uses Mintlify framework
|
| 97 |
- Files must be in docs.json to be included
|
| 98 |
- Never modify `docs/python-sdk/**` (auto-generated)
|
| 99 |
+
|
| 100 |
+
## Key Tools & Commands
|
| 101 |
+
|
| 102 |
+
### Environment Setup
|
| 103 |
+
```bash
|
| 104 |
+
git clone <repo>
|
| 105 |
+
cd fastmcp
|
| 106 |
+
uv sync # Installs all deps including dev tools
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
### Validation Commands (Run Frequently)
|
| 110 |
+
- **Linting**: `uv run ruff check` (or with `--fix`)
|
| 111 |
+
- **Type Checking**: `uv run pyright`
|
| 112 |
+
- **All Checks**: `uv run pre-commit run --all-files`
|
| 113 |
+
|
| 114 |
+
### Testing
|
| 115 |
+
- **Standard**: `uv run pytest`
|
| 116 |
+
- **Integration**: `uv run pytest -m "integration"`
|
| 117 |
+
- **Excluding markers**: `uv run pytest -m "not integration and not client_process"`
|
| 118 |
+
|
| 119 |
+
### CLI Usage
|
| 120 |
+
- **Run server**: `uv run fastmcp run server.py`
|
| 121 |
+
- **Development**: `uv run fastmcp dev server.py` (with Inspector UI)
|
| 122 |
+
- **Help**: `uv run fastmcp --help`
|
| 123 |
+
|
| 124 |
+
## Critical Patterns
|
| 125 |
+
|
| 126 |
+
### Error Handling
|
| 127 |
+
- Never use bare `except` - be specific with exception types
|
| 128 |
+
- Use `# type: ignore[attr-defined]` in tests for MCP results
|
| 129 |
+
|
| 130 |
+
### Build Issues (Common Solutions)
|
| 131 |
+
1. **Dependencies**: Always `uv sync` first
|
| 132 |
+
2. **Pre-commit fails**: Run `uv run pre-commit run --all-files` to see failures
|
| 133 |
+
3. **Type errors**: Use `uv run pyright` directly, check `pyproject.toml` config
|
| 134 |
+
4. **Test timeouts**: Default 3s - optimize or mark as integration tests
|