Commit graph

3,289 commits

Author SHA1 Message Date
Jeremiah Lowin
8a48146aad
Cleanly render oauth errors from proxy (#2268) 2025-10-26 21:08:05 -04:00
Jeremiah Lowin
5ceafe425c
Fix OAuth token storage documentation (#2272)
Correct imports (DiskStore not FileStore) and simplify structure.
2025-10-26 21:07:54 -04:00
Jeremiah Lowin
9a7c04873c
Add note about docs version (#2271) 2025-10-26 21:00:49 -04:00
Jeremiah Lowin
f5bdf8f6d3
Improve OAuth client token storage security documentation (#2270)
* Update docs for required scopes

* add scopes

* Fix Azure scope validation

Azure returns unprefixed scopes in JWT tokens but requires prefixed scopes in authorization requests. The previous implementation incorrectly validated tokens against prefixed scopes, causing "invalid_token" errors.

Simplified AzureProvider to use standard JWTVerifier with unprefixed scopes for validation. Scopes are only prefixed when building the Azure authorization URL via _build_upstream_authorize_url() override.

Closes #2263

* Improve OAuth client token storage security documentation

Updated warning message and documentation to address security concerns
around storing OAuth credentials for multiple MCP servers.
2025-10-26 20:04:54 -04:00
Jeremiah Lowin
8bd3a308c9
Update Azure sidebar title to include Entra ID (#2266)
* Update Azure sidebar title to include Entra ID

Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>

* Update Azure title to emphasize Microsoft Entra ID

Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>

* Update Azure title to emphasize Azure over Entra ID

Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>
2025-10-26 19:49:40 -04:00
Jeremiah Lowin
ba47db9b8c
Fix Azure scope validation (#2269) v2.13.0.1
* Update docs for required scopes

* add scopes

* Fix Azure scope validation

Azure returns unprefixed scopes in JWT tokens but requires prefixed scopes in authorization requests. The previous implementation incorrectly validated tokens against prefixed scopes, causing "invalid_token" errors.

Simplified AzureProvider to use standard JWTVerifier with unprefixed scopes for validation. Scopes are only prefixed when building the Azure authorization URL via _build_upstream_authorize_url() override.

Closes #2263
2025-10-26 11:41:22 -04:00
William Easton
9d4c378e1b
Add "High Value" Ruff Rules (#2255)
* Safe Fixes from ruff

* Fix remaining issues

* lint/check

* Fix mysterious ty check errors

* small cleanup

* pr fixes
2025-10-26 10:20:31 -04:00
Copilot
e74918a544
Add CI test job for lowest-direct dependency resolution (#2261)
* Initial plan

* Add test job for lowest-direct dependency resolution

Co-authored-by: strawgate <6384545+strawgate@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: strawgate <6384545+strawgate@users.noreply.github.com>
2025-10-26 10:16:54 -04:00
marvin-context-protocol[bot]
716e50dae0
chore: Update SDK documentation (#2214) v2.13.0
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
2025-10-25 08:52:43 -04:00
Jeremiah Lowin
5896daf6a1
Stage 2.13.0 updates (#2252)
* Add 2.13.0 updates

* Small tweaks
2025-10-25 08:52:21 -04:00
Jeremiah Lowin
b57a39c69c
Remove redundant None checks from Context methods (#2251) v2.13.0rc3
The fastmcp property already raises RuntimeError if None, making these checks unreachable.
2025-10-24 19:32:45 -04:00
William Easton
380835593c
Async FileResource and DirectoryResource (#2241)
* Improve DirectoryResource exception logging and async implementation

- Add exception logging before raising ResourceError in read() method
- Convert list_files() to async-native using anyio.Path
- Update read() to await async list_files() and use async is_file() check
- Remove synchronous thread wrapper in favor of native async I/O

Co-authored-by: William Easton <strawgate@users.noreply.github.com>

* Clean-up DirectoryResource

* Update src/fastmcp/resources/types.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: William Easton <strawgate@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-24 19:25:15 -04:00
William Easton
1e5776f69c
Add list_resources, list_prompts, and get_prompt methods to Context (#2249)
* Add list_resources, list_prompts, and get_prompt methods to Context

- Add Context.list_resources() to list all available resources
- Add Context.list_prompts() to list all available prompts
- Add Context.get_prompt() to get a specific prompt with arguments
- Update ToolInjectionMiddleware to use new Context methods instead of creating temporary Client instances
- Remove unused Client and FastMCPTransport imports from tool_injection.py

This improves API consistency by allowing middleware/tools to use Context methods directly without needing to create temporary Client instances.

Fixes #2245

Co-authored-by: William Easton <strawgate@users.noreply.github.com>

* Update docs

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: William Easton <strawgate@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-10-24 19:24:02 -04:00
William Easton
2f13119684
Add Documentation for FastMCP Server Testing (#2244)
* Add doc with recommendations for server testing

* Updates to testing doc

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* add to sidebar under patterns

* Update docs/patterns/testing.mdx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-24 19:11:21 -04:00
William Easton
c002bc389c
Small Clean-up (#2247)
* Project Clean-up

* Move pytest-asyncio to dev dependencies and update agents.md
2025-10-24 19:11:01 -04:00
Jeremiah Lowin
19fbc8435e
delete ratio test (#2250) 2025-10-24 19:10:19 -04:00
William Easton
063ffe9f64
Derive jwt_signing_key from Client Secret, default to Encrypted Disk Store (#2223)
* Checkpoint progress

* Checkpoint progress

* add derive b64 method

* PR clean-up

* refactor da proxy

* Updates to tests

* Make jwt_signing_key required for oauth proxy

* use typing_extensions and fix tests

* PR Cleanup

* also adjust integration tests

* Update docs, use client secret to derive jwt signing key

* You win some you lose some, gg claude

* check for both in derive

* update documentation / clean up

* Update http.mdx

---------

Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-10-24 19:08:58 -04:00
Jeremiah Lowin
577ed6e9a3
Fix middleware example: add context parameter to call_next() (#2215)
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>
2025-10-24 18:41:00 -04:00
Jeremiah Lowin
65260c91d5
Add version badge for run_server_async in tests docs (#2237)
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>
2025-10-24 18:40:30 -04:00
Adam Azzam
69b273ee8e
Add exc_info=True to inspect command error logging (#2232)
Fixes #2231

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-24 18:20:45 -04:00
William Easton
f5dbabff4e
Add ToolInjectionMiddleware + Tools for Read/List Resource/Prompt for Client Compat (#2142)
* Add compatibility tools contrib module

Implements four standalone tools that expose resources and prompts
as callable tools for clients that only support the tools capability.

Features:
- list_resources: List all available resources
- get_resource: Read a resource by URI
- list_prompts: List all available prompts
- get_prompt: Get a prompt with optional arguments

The tools use Context to access the server instance and can be easily
added to any FastMCP server using the add_compatibility_tools helper
or by adding individual tool instances directly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: William Easton <strawgate@users.noreply.github.com>

* Simplify compatibility tools to return raw MCP protocol objects

Return raw MCP protocol objects (ListResourcesResult, ReadResourceResult,
ListPromptsResult, GetPromptResult) instead of custom dictionaries. This
makes the tools simpler and more predictable by directly exposing what
the client methods return.

Co-authored-by: William Easton <strawgate@users.noreply.github.com>

* Add tool injection middleware

* cleanup contrib module

* More clean-up

* Clean up tool injection middleware.

* Update src/fastmcp/server/middleware/tool_injection.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add tool injection docs

* Small cleanup of prompt middleware

* PR Feedback

* Fix tool injection tests

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: William Easton <strawgate@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-24 18:06:58 -04:00
William Easton
c1e154ad66
Use abstract types for FastMCP class instantiation (#2219)
* feat: use abstract collection types in FastMCP.__init__

Use Sequence, Collection, and Mapping from collections.abc for more
flexible typing in FastMCP.__init__ parameters. This allows downstream
developers to pass tuples, sets, and other collection types instead of
being restricted to list and dict.

Changes:
- middleware: list -> Sequence (converted to list internally)
- tools: list -> Sequence
- tool_transformations: dict -> Mapping (ToolManager updated)
- include_tags: set -> Collection
- exclude_tags: set -> Collection
- dependencies: kept as list per maintainer request

Closes #2212

Co-authored-by: William Easton <strawgate@users.noreply.github.com>

* Concrete types in class inits

* Small imports cleanup

* Fix include/exclude tag handling

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: William Easton <strawgate@users.noreply.github.com>
2025-10-24 17:50:07 -04:00
Jeremiah Lowin
a1a5cca765
Fix Azure scope mismatch causing MCP client validation errors (#2243)
* Fix Azure scope mismatch causing MCP client validation errors

The AzureProvider was prefixing scopes during authorization but not in
token validation or Protected Resource Metadata, causing MCP clients to
reject tokens with "Server granted unauthorized scopes".

Changes:
- Prefix required_scopes once during __init__ and use consistently
- Pass prefixed scopes to JWTVerifier for token validation
- PRM now advertises prefixed scopes to MCP clients
- Remove unnecessary idempotent prefixing logic in authorize()
- Update comprehensive documentation explaining scope handling
- Update tests to reflect corrected behavior

Closes #2151

* Clarify that identifier_uri is optional in docstring
2025-10-24 17:45:49 -04:00
William Easton
fe0b49484b
Merge pull request #2242 from jlowin/claude/issue-2239-20251024-2057
Mark test_github_api_schema_performance as integration test
2025-10-24 16:12:22 -05:00
William Easton
f614b20150
Merge branch 'main' into claude/issue-2239-20251024-2057 2025-10-24 16:08:28 -05:00
William Easton
9e964a4c92
Fix martian concurrency controls and dedupe issues mcp servers
Fix martian concurrency controls and dedupe issues mcp servers
2025-10-24 16:07:56 -05:00
claude[bot]
638111990d Mark test_github_api_schema_performance as integration test
This test makes external HTTP requests to GitHub and is subject to
network latency, causing CI timeouts. Marking it as an integration test
excludes it from default test runs while keeping it available for
explicit integration testing.

Co-authored-by: William Easton <strawgate@users.noreply.github.com>
2025-10-24 20:59:55 +00:00
William Easton
da4a969d72
WS diff 2025-10-24 15:58:51 -05:00
William Easton
bd4b6e6db3
Fix martian concurrency controls and dedupe issues mcp servers 2025-10-24 15:55:32 -05:00
Jeremiah Lowin
980d0516a7
Expose OAuth token management parameters in all providers (#2222)
All OAuth providers and OIDCProxy now expose jwt_signing_key,
token_encryption_key, and client_storage parameters for production
deployments requiring persistent token management across server restarts.
2025-10-22 21:51:37 -04:00
Jeremiah Lowin
562e51b378
Improve OAuth error messages with custom handlers and middleware (#2221)
* Enhance OAuth Proxy error responses with branded HTML pages

OAuth Proxy authentication errors now show styled HTML error pages in browsers
instead of raw JSON, with content negotiation for API clients. Enhanced error
messages explain common causes (ephemeral storage, server restarts) and provide
clear remediation steps.

Changes:
- Created enhanced authorization handler that extends SDK's AuthorizationHandler
- Created enhanced auth middleware that extends SDK's RequireAuthMiddleware
- HTML error pages use server branding (icon, name) from FastMCP instance
- Added comprehensive troubleshooting section to OAuth Proxy docs
- Added FAQ entry linking to detailed troubleshooting

* Add comprehensive tests for enhanced OAuth error responses

Tests cover:
- HTML error pages for browser requests with server branding
- Enhanced JSON responses with registration endpoint hints
- Content negotiation between HTML and JSON
- Enhanced middleware error messages for invalid_token
- WWW-Authenticate header format consistency with SDK

* Update language for new storage defaults

* update docs

* Update tests for simplified error messages

* Clean up messages
2025-10-22 21:29:14 -04:00
Jeremiah Lowin
e3d1750412
Update CLI logo (#2220) 2025-10-22 21:29:04 -04:00
Jeremiah Lowin
686082a5b5
Add platform-aware OAuth token persistence (#2218)
* Add comprehensive keyring integration tests

Prevents OS keyring pollution during testing by adding a global mock in
conftest.py. Tests verify keyring behavior across platforms and fallback
scenarios without writing to the actual system keyring.

- Add global mock_keyring fixture to tests/conftest.py
- Add TestOAuthProxyKeyring class with 6 keyring-specific tests
- Remove try/except ImportError for keyring (now required dependency)
- Add keyring extra to py-key-value-aio dependency
- Clean up extraneous implementation comments in oauth_proxy.py

* Update OAuth keyring documentation

Update all OAuth-related documentation to reflect keyring-based key management:
- Add version badges to jwt_signing_key, token_encryption_key, and client_storage parameters
- Standardize "Default behavior (`None`):" formatting with backticks
- Ensure consistent messaging about development-only defaults across all docs
- Update oauth-proxy.mdx, oidc-proxy.mdx, http.mdx, storage-backends.mdx, and upgrade-guide.mdx
2025-10-22 20:42:24 -04:00
William Easton
df7a485869
Merge pull request #2217 from jlowin/claude/issue-2216-20251022-2311
Fix dead links to py-key-value repository
2025-10-22 19:09:35 -05:00
claude[bot]
f127e33bbe Fix dead links to py-key-value repository
Update documentation links from py-key-value-aio to py-key-value repository.
The py-key-value-aio package lives in the py-key-value monorepo.

Co-authored-by: William Easton <strawgate@users.noreply.github.com>
2025-10-22 23:15:03 +00:00
Jeremiah Lowin
8099201979
Use platformdirs for settings.home (#2213)
Changes settings.home from `Path.home() / ".fastmcp"` to use platformdirs.user_data_dir(), following platform conventions (~/Library/Application Support on macOS, ~/.local/share on Linux, %APPDATA% on Windows).
2025-10-22 16:06:46 -04:00
nate nowack
72b9acd707
Merge pull request #2201 from jlowin/update-smart-home-example-again
Update smart home example again
2025-10-21 20:32:02 -05:00
zzstoatzz
2ff72476b1 example: allow any str for bridge IP 2025-10-21 20:25:43 -05:00
zzstoatzz
bfa8ec43c1 example: allow any str for bridge IP 2025-10-21 20:25:31 -05:00
nate nowack
62ed19fb68
Merge pull request #2200 from jlowin/update-smart-home-example
example: update server init usage
2025-10-21 19:39:43 -05:00
zzstoatzz
29b0330882 example: update server init usage 2025-10-21 19:34:08 -05:00
William Easton
ac62a06158
Merge pull request #2196 from jlowin/bump-kv-aio
Bump py-key-value-aio to 0.2.6
2025-10-21 13:24:22 -05:00
William Easton
c833fff63c
Bump to 0.2.6 2025-10-21 11:38:07 -05:00
marvin-context-protocol[bot]
811e516699
chore: Update SDK documentation (#2171)
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
2025-10-21 11:32:32 -04:00
Valay Dave
19e97454a0
bug fix in fastmcp install claude-code (#2165)
* bug fix in `fastmcp install claude-code`

Calling the CLI like below command doenst end up working: 

```
fastmcp install claude-code "$SERVER_FILE" \
    --python 3.12 \
    --env "DOCS_DIR=$DOCS_DIR" \
    --env "ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY" \
    --with fastmcp \
    --with anthropic \
    --with click
```

It errors out like: 

```
Failed to install 'foo-mcp' in Claude Code: Invalid environment variable format: foo-mcp, environment variables should be added as: -e KEY1=value1 
-e KEY2=value2
```

The fix was simply ensuring that the claude code mcp command gets mcp name directly.

* Apply suggestion from @jlowin

---------

Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-10-21 10:19:34 -04:00
Jeremiah Lowin
908d085533
Restore gray monospace styling for OAuth callback screen (#2173) 2025-10-21 10:02:50 -04:00
Jeremiah Lowin
4d609ce74b
Move sampling fallback handler docs to server section (#2163) 2025-10-21 10:02:11 -04:00
Lukas Innig
f27a6fcd7a
Update environment vars in uvx transport (#2169)
The UvxStdioTransport class is not adding extra environment variables - like e.g. the NpxStdioTransport already does
2025-10-21 10:01:50 -04:00
Jeremiah Lowin
9987a456a0
Allow authorization consent screen to be disabled (#2172)
* Add optional authorization consent screen for OAuth providers

Adds `require_authorization_consent` parameter (default True) to OAuthProxy and all providers. When disabled, authorization skips the consent screen for local development/testing. Logs security warning when disabled.

* Update warning message to use 'authorization consent screen'
2025-10-21 10:00:39 -04:00
Jeremiah Lowin
422374c7bc
Remove fonts which weren't rendering in all browsers (#2174) 2025-10-21 10:00:27 -04:00