Jeremiah Lowin commited on
Commit
b8a5dcf
·
unverified ·
1 Parent(s): e4fc893

Update AGENTS.md (#1471)

Browse files
Files changed (1) hide show
  1. AGENTS.md +56 -14
AGENTS.md CHANGED
@@ -23,18 +23,18 @@ uv run pytest # Run full test suite
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) |
@@ -42,6 +42,7 @@ uv run pytest # Run full test suite
42
  ## Core MCP Objects
43
 
44
  When modifying MCP functionality, changes typically need to be applied across all object types:
 
45
  - **Tools** (`src/tools/` + `ToolManager`)
46
  - **Resources** (`src/resources/` + `ResourceManager`)
47
  - **Resource Templates** (`src/resources/` + `ResourceManager`)
@@ -49,6 +50,15 @@ When modifying MCP functionality, changes typically need to be applied across al
49
 
50
  ## Testing Best Practices
51
 
 
 
 
 
 
 
 
 
 
52
  ### Always Use In-Memory Transport
53
 
54
  Pass FastMCP servers directly to clients for testing:
@@ -66,6 +76,7 @@ async with Client(mcp) as client:
66
  ```
67
 
68
  Only use HTTP transport when explicitly testing network features:
 
69
  ```python
70
  # Network testing only
71
  async with Client(transport=StreamableHttpTransport(server_url)) as client:
@@ -75,31 +86,57 @@ async with Client(transport=StreamableHttpTransport(server_url)) as client:
75
  ## Development Rules
76
 
77
  ### Git & CI
 
78
  - Pre-commit hooks are required (run automatically on commits)
79
  - Never amend commits to fix pre-commit failures
80
  - Apply PR labels: bugs/breaking/enhancements/features
81
  - Improvements = enhancements (not features) unless specified
 
 
82
 
83
  ### Commit Messages and Agent Attribution
84
- - **NEVER** include agent attribution in commit messages or PR titles/descriptions (no "🤖 Generated with [tool]", "with Claude", etc.)
85
- - Agent attribution is ONLY allowed in Co-authored-by lines in commits
86
  - Keep commit messages brief - ideally just headlines, not detailed messages
87
  - Focus on what changed, not how or why
 
 
 
 
 
 
 
 
 
 
88
 
89
  ### Code Standards
 
90
  - Python ≥ 3.10 with full type annotations
91
  - Follow existing patterns and maintain consistency
 
 
92
  - Use `# type: ignore[attr-defined]` in tests for MCP results instead of type assertions
93
  - Each feature needs corresponding tests
94
 
95
  ### Documentation
 
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
@@ -107,16 +144,19 @@ 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`
@@ -124,10 +164,12 @@ uv sync # Installs all deps including dev tools
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
 
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) |
 
42
  ## Core MCP Objects
43
 
44
  When modifying MCP functionality, changes typically need to be applied across all object types:
45
+
46
  - **Tools** (`src/tools/` + `ToolManager`)
47
  - **Resources** (`src/resources/` + `ResourceManager`)
48
  - **Resource Templates** (`src/resources/` + `ResourceManager`)
 
50
 
51
  ## Testing Best Practices
52
 
53
+ ### Testing Standards
54
+
55
+ - Every test: atomic, self-contained, single functionality
56
+ - Use parameterization for multiple examples of same functionality
57
+ - Use separate tests for different functionality pieces
58
+ - Put imports at the top of the file, not in the test body
59
+ - **NEVER** add `@pytest.mark.asyncio` to tests - `asyncio_mode = "auto"` is set globally
60
+ - **ALWAYS** run pytest after significant changes
61
+
62
  ### Always Use In-Memory Transport
63
 
64
  Pass FastMCP servers directly to clients for testing:
 
76
  ```
77
 
78
  Only use HTTP transport when explicitly testing network features:
79
+
80
  ```python
81
  # Network testing only
82
  async with Client(transport=StreamableHttpTransport(server_url)) as client:
 
86
  ## Development Rules
87
 
88
  ### Git & CI
89
+
90
  - Pre-commit hooks are required (run automatically on commits)
91
  - Never amend commits to fix pre-commit failures
92
  - Apply PR labels: bugs/breaking/enhancements/features
93
  - Improvements = enhancements (not features) unless specified
94
+ - **NEVER** force-push on collaborative repos
95
+ - **ALWAYS** run pre-commit before PRs
96
 
97
  ### Commit Messages and Agent Attribution
98
+
99
+ - **Agents NOT acting on behalf of @jlowin MUST identify themselves** (e.g., "🤖 Generated with Claude Code" in commits/PRs)
100
  - Keep commit messages brief - ideally just headlines, not detailed messages
101
  - Focus on what changed, not how or why
102
+ - Always read issue comments for follow-up information (treat maintainers as authoritative)
103
+
104
+ ### PR Messages - Required Structure
105
+
106
+ - 1-2 paragraphs: problem/tension + solution (PRs are documentation!)
107
+ - Focused code example showing key capability
108
+ - **Avoid:** bullet summaries, exhaustive change lists, verbose closes/fixes, marketing language
109
+ - **Do:** Be opinionated about why change matters, show before/after scenarios
110
+ - Minor fixes: keep body short and concise
111
+ - No "test plan" sections or testing summaries
112
 
113
  ### Code Standards
114
+
115
  - Python ≥ 3.10 with full type annotations
116
  - Follow existing patterns and maintain consistency
117
+ - **Prioritize readable, understandable code** - clarity over cleverness
118
+ - Avoid obfuscated or confusing patterns even if they're shorter
119
  - Use `# type: ignore[attr-defined]` in tests for MCP results instead of type assertions
120
  - Each feature needs corresponding tests
121
 
122
  ### Documentation
123
+
124
  - Uses Mintlify framework
125
  - Files must be in docs.json to be included
126
  - Never modify `docs/python-sdk/**` (auto-generated)
127
+ - **Core Principle:** A feature doesn't exist unless it is documented!
128
+
129
+ ### Documentation Guidelines
130
+
131
+ - **Code Examples:** Explain before showing code, make blocks fully runnable (include imports)
132
+ - **Structure:** Headers form navigation guide, logical H2/H3 hierarchy
133
+ - **Content:** User-focused sections, motivate features (why) before mechanics (how)
134
+ - **Style:** Prose over code comments for important information
135
 
136
  ## Key Tools & Commands
137
 
138
  ### Environment Setup
139
+
140
  ```bash
141
  git clone <repo>
142
  cd fastmcp
 
144
  ```
145
 
146
  ### Validation Commands (Run Frequently)
147
+
148
  - **Linting**: `uv run ruff check` (or with `--fix`)
149
  - **Type Checking**: `uv run pyright`
150
  - **All Checks**: `uv run pre-commit run --all-files`
151
 
152
  ### Testing
153
+
154
  - **Standard**: `uv run pytest`
155
  - **Integration**: `uv run pytest -m "integration"`
156
  - **Excluding markers**: `uv run pytest -m "not integration and not client_process"`
157
 
158
  ### CLI Usage
159
+
160
  - **Run server**: `uv run fastmcp run server.py`
161
  - **Development**: `uv run fastmcp dev server.py` (with Inspector UI)
162
  - **Help**: `uv run fastmcp --help`
 
164
  ## Critical Patterns
165
 
166
  ### Error Handling
167
+
168
  - Never use bare `except` - be specific with exception types
169
  - Use `# type: ignore[attr-defined]` in tests for MCP results
170
 
171
  ### Build Issues (Common Solutions)
172
+
173
  1. **Dependencies**: Always `uv sync` first
174
  2. **Pre-commit fails**: Run `uv run pre-commit run --all-files` to see failures
175
  3. **Type errors**: Use `uv run pyright` directly, check `pyproject.toml` config