Skip to content

🚀 The fast, Pythonic way to build MCP servers and clients.

Use scoped local tests and leave full suites to CI (#6094)

nate nowack3fe80e9bc3a2
diff --git a/.agents/skills/python-tests/SKILL.md b/.agents/skills/python-tests/SKILL.md
index ba5f8bc4f..aa6996718 100644
--- a/.agents/skills/python-tests/SKILL.md
+++ b/.agents/skills/python-tests/SKILL.md
@@ -18,4 +18,9 @@ For a bug fix, run the regression against unchanged code and confirm it fails fo
- Use existing `inline_snapshot` conventions for complex schema assertions. Inspect generated snapshots rather than accepting them blindly.
- The default timeout is five seconds. Use the repository's integration conventions for tests that legitimately need more time.
-Run focused tests during development, then the full commands required by AGENTS.md before committing. If a failure appears unrelated, reproduce it on the unchanged base; do not call it pre-existing from the test name alone.
+Run relevant tests and applicable static checks before committing. Broaden local
+testing when a concrete dependency or failure warrants it; leave routine full-suite
+and platform-matrix runs to CI. Do not repeat the full suite for each layer in a
+stack. Follow AGENTS.md for the local verification policy. If a failure appears
+unrelated, reproduce it on the unchanged base; do not call it pre-existing from
+the test name alone.
diff --git a/AGENTS.md b/AGENTS.md
index 091a401c0..d115ff1a0 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -6,14 +6,33 @@ FastMCP is a comprehensive Python framework (Python ≥3.10) for building Model
## Required Development Workflow
-**CRITICAL**: Always run these commands in sequence before committing.
+Install dependencies before running local checks:
```bash
uv sync # Install dependencies
-uv run pytest -n auto # Run full test suite
```
-In addition, you must pass static checks. This is generally done as a pre-commit hook with `prek` but you can run it manually with:
+Run the tests relevant to the behavior you changed, including neighboring paths
+that share the implementation. For example:
+
+```bash
+uv run pytest tests/skills tests/utilities/test_skills.py -n 0
+```
+
+Broaden the selection when a concrete dependency or failure warrants it and the
+check is expedient. Full-suite and platform-matrix testing belong in CI; do not
+run the full suite locally by default or repeat it for each commit or PR in a
+stack. Run it locally only when explicitly requested or when investigating a
+failure that requires it.
+
+In addition, you must pass static checks. These generally run as pre-commit hooks
+with `prek`. To check changed files before committing:
+
+```bash
+uv run prek run --files path/to/changed_file.py
+```
+
+For repository-wide configuration changes, run:
```bash
uv run prek run --all-files # Ruff + Prettier + ty + gitleaks
@@ -21,7 +40,7 @@ uv run prek run --all-files # Ruff + Prettier + ty + gitleaks
The gitleaks hook needs the `gitleaks` binary on `PATH` (`brew install gitleaks`, or see [gitleaks releases](https://github.com/gitleaks/gitleaks/releases)) — it isn't a `uv`-managed dependency, so `uv sync` alone won't provide it.
-**Tests must pass and lint/typing must be clean before committing.**
+**Relevant tests and applicable static checks must pass before committing.**
## Repository Structure
@@ -81,8 +100,8 @@ When modifying MCP functionality, changes typically need to be applied across al
- Never amend commits to fix prek failures
- Never apply labels manually or invent new ones — issues and PRs are auto-labeled by a bot based on title/body/code changes. Don't note a "suggested" or "appropriate" label anywhere in the PR body either. See the review-pr skill.
- Improvements = enhancements (not features) unless specified
-- **NEVER** force-push on collaborative repos
-- **ALWAYS** run prek before PRs
+- Rebase PR branches when needed. Publish rewritten history with `--force-with-lease` against the verified remote head; use an atomic push when updating a stack. Never overwrite another contributor’s new work or rewrite shared release branches. A requested rebase includes publishing it safely; it does not require separate permission for the lease-protected push.
+- **ALWAYS** run applicable prek checks before PRs
- **NEVER** create a release, comment on an issue, or open a PR unless specifically instructed to do so.
- **NEVER** merge a PR marked as do-not-merge or draft. Check title, body, AND labels for `[DNM]`, `DNM`, `DO NOT MERGE`, `DON'T MERGE`, `DONT MERGE`, `do-not-merge`, `dont-merge`, `[DRAFT]`, or `DRAFT` (case-insensitive, any variation — some authors use `[DRAFT]` in the title even when `isDraft` is false). Authors use these as hard stops — respect them even if CI is green and review looks clean. When triaging a batch of PRs, filter these out up front AND re-check each one's labels immediately before merging, since labels can change mid-session.
- **ALWAYS** read review-bot comments before approving a PR. chatgpt-codex-connector (Codex) and claude[bot] leave substantive review comments on most PRs in this repo — these bots have read the diff and often flag real issues that aren't in the PR description. Use `gh pr view <num> --comments` and read the bot feedback as part of review. Unlike proposed solutions from issue reporters, review-bot feedback should be evaluated on its merits, not discounted.
diff --git a/docs/development/contributing.mdx b/docs/development/contributing.mdx
index 44f0cd868..b17c93c26 100644
--- a/docs/development/contributing.mdx
+++ b/docs/development/contributing.mdx
@@ -67,16 +67,24 @@ Keep the change scoped to one problem and fix the causal code path. Avoid specul
For a bug fix, run the regression on unchanged code and confirm it fails for the reported reason, then run it with the fix. Assert the actual result and relevant types. Exercise neighboring supported behavior as well. The [Testing Guide](/development/tests) covers fixtures, protocol tests, HTTP helpers, and subprocess tests.
-Before committing, run these commands in order, followed by the static checks:
+Before committing, install dependencies and run the tests relevant to your change,
+including neighboring behavior that shares its implementation. For example, a
+skills change can use:
```bash
uv sync
-uv run pytest -n auto
-uv run prek run --all-files
+uv run pytest tests/skills tests/utilities/test_skills.py -n 0
+uv run prek run --files path/to/changed_file.py
```
Prek runs lint, formatting, typing, and other repository checks; pytest is separate. Hooks also run on commit. Fix failures before committing, and use a new commit rather than amending to repair a failed hook.
+Broaden local testing when a concrete dependency or failure warrants it and the
+check is expedient. Routine full-suite and platform-matrix runs belong in CI;
+do not repeat them locally for each commit or PR in a stack. Run the full suite
+locally when explicitly requested or when investigating a failure that requires
+it. Repository-wide configuration changes may also need `uv run prek run --all-files`.
+
## Update documentation
Document new capabilities and changes to public behavior alongside the implementation. Explain the use case before the code, include imports, and keep examples runnable. Add new pages to `docs/docs.json` so they appear in navigation. When a setting changes, update `docs/more/settings.mdx`.
@@ -116,4 +124,4 @@ Decide whether FastMCP wants a change before verifying it. Name who hits the pro
Labels such as `high-priority` and confident diagnoses from bots or commenters are claims, not evidence. Before treating an issue as a bug, confirm its current state, since a fix may already be merged or reverted, and check whether the behavior is a decision already made in maintainer comments, closed PRs, upgrade guides, or docs. Close a settled decision with that history linked; leave a deferred design open as its tracker. When intended behavior surprises users, fix the docs or the behavior rather than adding a warning.
-When PRs compete for one issue, prefer the reporter's, then the one fixing the right layer with a real regression test, then the smaller one. Before merging several PRs together, merge them onto current `main` and run the full suite and static checks there, and confirm CI actually ran on each PR's current head: fork PR runs can wait for approval, and runs older than a month cannot be re-run, so update the branch instead.
+When PRs compete for one issue, prefer the reporter's, then the one fixing the right layer with a real regression test, then the smaller one. Before merging several PRs together, verify their composition on current `main` with relevant tests and applicable static checks, and confirm full CI actually ran on the combined revision. Fork PR runs can wait for approval, and runs older than a month cannot be re-run, so update the branch instead.
diff --git a/docs/development/tests.mdx b/docs/development/tests.mdx
index f6e1e226c..0fd8378cb 100644
--- a/docs/development/tests.mdx
+++ b/docs/development/tests.mdx
@@ -8,11 +8,12 @@ Test the behavior a user relies on through the smallest boundary that exercises
## Run tests
-Install the repository dependencies before running tests:
+Install the repository dependencies and select the tests relevant to your change.
+For example, to check client behavior:
```bash
uv sync
-uv run pytest -n auto
+uv run pytest tests/client/client/test_client.py -n 0
```
During development, run the owning test module or select a behavior by name:
@@ -28,6 +29,11 @@ Use `-n 0` for a single process when debugging. The full suite uses pytest-xdist
uv run pytest -n auto -m "not integration and not client_process and not subprocess_heavy and not conformance"
```
+Broaden local coverage when a concrete dependency or failure warrants it. Leave
+routine full-suite and platform-matrix runs to CI, rather than repeating them for
+each commit or PR in a stack. Run `uv run pytest -n auto` locally when explicitly
+requested or when investigating a failure that requires the full suite.
+
The default timeout is five seconds, and `asyncio_mode = "auto"` enables async tests without `@pytest.mark.asyncio`. These settings and the registered markers live in [pyproject.toml](https://github.com/PrefectHQ/fastmcp/blob/main/pyproject.toml).
### Test organization and markers
@@ -251,4 +257,4 @@ uv run pytest tests/docs -n 0
The docs tests parse Python fences and resolve FastMCP imports. They do not execute every example or detect every missing non-import name, so run changed examples yourself. Use `just docs` to preview rendering. Without just, run `npx --yes mint@latest broken-links` or `npx --yes mint@latest dev` from `docs/`.
-See the [Contributing Guide](/development/contributing#implement-and-verify) for the full checks required before committing.
+See the [Contributing Guide](/development/contributing#implement-and-verify) for local checks before committing and CI expectations.