Skip to content

Commit 740b8f8

Browse files
committed
docs: address review feedback on AGENTS.md
- Fix test-mirror example to use a path that actually exists (src/mcp/client/stdio.py -> tests/client/test_stdio.py) - Add upstream-library carve-out to the filterwarnings rule, since pyproject.toml already has scoped ignore:: entries for websockets/pywin32 - Document Raises: sections for public APIs that raise catchable exceptions
1 parent b8895ae commit 740b8f8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

AGENTS.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
## Code Quality
3232

3333
- Type hints required for all code
34-
- Public APIs must have docstrings
34+
- Public APIs must have docstrings. When a public API raises exceptions a
35+
caller would reasonably catch, document them in a `Raises:` section. Don't
36+
list exceptions from argument validation or programmer error.
3537
- `src/mcp/__init__.py` defines the public API surface via `__all__`. Adding a
3638
symbol there is a deliberate API decision, not a convenience re-export.
3739
- IMPORTANT: All imports go at the top of the file — inline imports hide
@@ -50,16 +52,17 @@
5052
cleanest approach (see `tests/client/test_client.py` for the canonical
5153
pattern). For narrower changes, testing the function directly is fine. Use
5254
judgment.
53-
- Test files mirror the source tree: `src/mcp/client/streamable_http.py`
54-
`tests/client/test_streamable_http.py`. Add tests to the existing file for that module.
55+
- Test files mirror the source tree: `src/mcp/client/stdio.py`
56+
`tests/client/test_stdio.py`. Add tests to the existing file for that module.
5557
- Avoid `anyio.sleep()` with a fixed duration to wait for async operations. Instead:
5658
- Use `anyio.Event` — set it in the callback/handler, `await event.wait()` in the test
5759
- For stream messages, use `await stream.receive()` instead of `sleep()` + `receive_nowait()`
5860
- Exception: `sleep()` is appropriate when testing time-based features (e.g., timeouts)
5961
- Wrap indefinite waits (`event.wait()`, `stream.receive()`) in `anyio.fail_after(5)` to prevent hangs
6062
- Pytest is configured with `filterwarnings = ["error"]`, so warnings fail
61-
tests. Don't silence them with `filterwarnings` or `warnings.catch_warnings()`;
62-
fix the underlying cause instead.
63+
tests. Don't silence warnings from your own code; fix the underlying cause.
64+
Scoped `ignore::` entries for upstream libraries are acceptable in
65+
`pyproject.toml` with a comment explaining why.
6366

6467
### Coverage
6568

0 commit comments

Comments
 (0)