Commit graph

477 commits

Author SHA1 Message Date
Jeremiah Lowin
ddb557ba30 Update for 'result' kwarg instead of 'value' 2025-06-27 15:44:46 -04:00
Jeremiah Lowin
d8dc28b9b2 Add structured content & update almost all tests 2025-06-27 15:40:52 -04:00
Jeremiah Lowin
7f0622b707 Fix contrib tests 2025-06-26 20:17:02 -04:00
Jeremiah Lowin
1e29149d5f Merge branch 'main' into output-schema 2025-06-26 19:30:35 -04:00
Jeremiah Lowin
78f0196db5 Fix OpenAPI tests 2025-06-26 18:21:52 -04:00
Jeremiah Lowin
7b9696405b Remove legacy json parsing
Because the server now validates inputs, its no longer viable to provide a JSON string where e.g. an array is expected, so we can entirely remove FastMCP's "legacy json parsing" support from 1.x.

This is a breaking change (for legacy opt-in behavior)
2025-06-26 18:19:43 -04:00
Jeremiah Lowin
9d51bca0d8 Merge branch 'main' into protocol-update 2025-06-26 18:13:59 -04:00
Jeremiah Lowin
ddb38bacc4 Fix middleware tests 2025-06-26 18:13:32 -04:00
Jeremiah Lowin
6b2df6be51 Fix middleware tests 2025-06-26 17:57:30 -04:00
Jeremiah Lowin
aa66b81b73 Merge branch 'protocol-update' of https://github.com/jlowin/fastmcp into protocol-update 2025-06-26 15:22:41 -04:00
Jeremiah Lowin
b98b080c98 Implement TokenVerifier protocol for mcp-python-sdk compatibility
Fixes breaking changes from mcp-python-sdk PR #982 which updated
BearerAuthBackend to use TokenVerifier protocol instead of OAuth providers.

Changes:
- Add verify_token() method to BearerAuthProvider implementing TokenVerifier protocol
- Add verify_token() method to InMemoryOAuthProvider implementing TokenVerifier protocol
- Update BearerAuthBackend usage in setup_auth_middleware_and_routes() to pass TokenVerifier
- Add comprehensive unit tests for TokenVerifier implementations
- Add integration tests for BearerAuthBackend with TokenVerifier
- Add tests for HTTP auth setup functions

All existing functionality preserved with full backwards compatibility.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-26 15:08:31 -04:00
Jeremiah Lowin
0624a4ae53 Update tests for server input validation 2025-06-26 10:56:21 -04:00
Jeremiah Lowin
1fe4eb7a9d
Merge branch 'main' into notifications 2025-06-26 09:36:26 -04:00
Jeremiah Lowin
68ab760240 Merge branch 'main' into protocol-update 2025-06-26 09:25:39 -04:00
Jeremiah Lowin
159324ea46
Merge pull request #954 from jlowin/claude-wt-20250625-210215
Fix external schema reference handling in OpenAPI parser
2025-06-25 21:39:49 -04:00
Jeremiah Lowin
6584750667 Fix external schema reference handling in OpenAPI parser
Previously, external schema references (URLs) in OpenAPI schemas were
silently passed through and only failed during JSON schema validation
with confusing "failed to match exactly one schema" errors.

This change:
- Detects external references in _replace_ref_with_defs() and raises clear error messages
- Updates exception handlers to propagate external reference errors while preserving other error handling
- Adds comprehensive test coverage for external reference detection
- Provides helpful error messages explaining that FastMCP only supports local schema references

Fixes #926

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-25 21:25:06 -04:00
Jeremiah Lowin
e68fa0653b Use proper isinstance(Enum) check instead of hasattr
Replace hasattr(param_in, 'value') with isinstance(param_in, Enum)
for more robust enum detection as suggested in review.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-25 21:00:39 -04:00
Jeremiah Lowin
f566e9a60f Fix parameter location enum handling in OpenAPI parser
Fixes issue where ParameterLocation enum values from openapi_pydantic
were not properly converted to strings, causing validation errors.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-25 20:38:00 -04:00
Jeremiah Lowin
38036b1f42 Add automatic MCP list change notifications and client message handling
Implements comprehensive notification system for tools, resources, and prompts with automatic client updates and flexible message handlers.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-24 22:33:06 -04:00
Jeremiah Lowin
6d033eeaf1 Add production-ready middleware examples with comprehensive tests
Implements timing, logging, rate limiting, and error handling middleware to showcase
FastMCP's middleware capabilities as a headline feature. Each middleware includes:

- Production-ready implementations with full configurability
- Comprehensive unit and integration tests with real FastMCP servers
- Updated documentation with teaching examples and production usage patterns

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-22 21:57:49 -04:00
Jeremiah Lowin
987dd85826 Update test_streamable_http.py 2025-06-22 20:08:36 -04:00
Jeremiah Lowin
ffe0c92d63 Alias streamable-http as http 2025-06-22 20:00:11 -04:00
Jeremiah Lowin
76e3df1bc1 Add "http" as an alias for streamable-http 2025-06-22 18:55:07 -04:00
Jeremiah Lowin
9b85d492e8 Add http as an alias for streamable http 2025-06-22 18:35:28 -04:00
Jeremiah Lowin
0142bb2af1
Merge branch 'protocol-update' into output-schema 2025-06-22 13:46:26 -04:00
Jeremiah Lowin
eb00f2238b Merge branch 'main' into protocol-update 2025-06-22 13:45:29 -04:00
Jeremiah Lowin
73e1aa2112 Apply pre-commit formatting changes
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-22 10:29:15 -04:00
Jeremiah Lowin
a7f14d90a4 Implement client-side argument serialization with focused tests
- Add pydantic_core.to_json() serialization for non-string prompt arguments
- Update type annotations to accept dict[str, Any] instead of dict[str, str]
- Add focused tests covering specific scenarios:
  * Client always serializes non-string args regardless of server types
  * Integration with server-side type conversion
  * Client serialization error with specific PydanticSerializationError
  * Server deserialization error with specific McpError match

This ensures MCP protocol compliance while maintaining developer experience
with typed arguments.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-22 10:18:48 -04:00
Jeremiah Lowin
9714028cac Fix pyright type checking issues in tests
Add proper null checks and type assertions for prompt argument
handling in tests to satisfy pyright strict typing.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-22 09:55:40 -04:00
Jeremiah Lowin
7114242e1e Update schema description wording for clarity
Change from 'Arguments must be strings conforming to this JSON schema'
to 'Provide as a JSON string matching the following schema' for clearer
instruction to LLMs about string format requirements.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-22 09:46:11 -04:00
Jeremiah Lowin
817018bf3b Add automatic JSON schema descriptions for non-string prompt arguments
- Fix ValueError -> PromptError for consistent error handling
- Add automatic JSON schema descriptions to non-string prompt arguments
- Include comprehensive tests for argument description enhancement
- Verify enhanced descriptions are visible via MCP protocol

This helps developers understand the expected string format for complex
types when calling prompts from MCP clients.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-22 09:38:57 -04:00
Jeremiah Lowin
7a793f4309 Fix prompt argument type annotation to support mixed typing
Updated FunctionPrompt.render() to accept dict[str, Any] instead of
dict[str, str | Context] to preserve the developer experience of
passing properly typed arguments while also supporting string-only
arguments from MCP clients.

The _convert_string_arguments method now intelligently handles both
scenarios:
- Already-typed arguments are passed through unchanged
- String arguments are converted to expected types when needed

This maintains backward compatibility while enabling MCP spec compliance.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-22 08:34:49 -04:00
Jeremiah Lowin
8506f78453 Fix event loop conflict in inspect CLI command
Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-21 20:04:39 -04:00
Jeremiah Lowin
6a3a3077b7 Add fastmcp inspect command with detailed server analysis
- Add comprehensive server inspection utility supporting both FastMCP 1.x and 2.x
- Create detailed info dataclasses for tools, prompts, resources, and templates
- Implement CLI command with path:object notation and JSON output
- Add version reporting (fastmcp_version, mcp_version, server_version)
- Include comprehensive unit tests for utilities and CLI

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-21 16:40:54 -04:00
Jeremiah Lowin
cc69e56758 Add output schema to tool decorator 2025-06-20 18:58:23 -04:00
Jeremiah Lowin
337c2f8db5
Merge pull request #897 from owtaylor/openapi-recursive-components 2025-06-20 18:43:27 -04:00
Jeremiah Lowin
3bc585788f Add output schema to tools 2025-06-20 17:54:07 -04:00
Owen W. Taylor
14d1b8a94d openapi: Rewrite recursive #/components/schemas/ references
When a schema referenced another schema as #/components/schemas/...
that wasn't properly rewritten into #/$defs/..
2025-06-20 14:34:47 -04:00
Owen W. Taylor
bbf8165636 openapi: Improve pruning of unused defs
Defs that are used only by other unused defs were counted as
used. Fix this by tracing what defs use other defs recursively.
2025-06-20 14:34:41 -04:00
Jeremiah Lowin
fbe2fc3533 Add transport handling for trailing slashes 2025-06-20 13:12:23 -04:00
Jeremiah Lowin
18ae625fef Update docs and test 2025-06-20 13:06:48 -04:00
Jeremiah Lowin
a2f406faa4 Apply pre-commit formatting fixes 2025-06-20 12:17:47 -04:00
Jeremiah Lowin
42460480de Fix BearerAuthProvider audience type annotations to support List[str]
The audience parameter was typed as `str | None` but the implementation
already supported `List[str]`. This fix aligns the type annotations with
the actual functionality and adds comprehensive validation logic for all
audience type combinations.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-20 12:13:00 -04:00
Jeremiah Lowin
40ce687d0d Fix JWT issuer validation to support string values per RFC 7519
Resolves issue where BearerAuthProvider rejected tokens with non-URL
issuer claims. Works around the underlying SDK's URL validation while
maintaining RFC 7519 compliance for JWT processing.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-20 11:47:34 -04:00
Jeremiah Lowin
02b2ec1adf Update types and tests for upcoming SDK release 2025-06-20 09:56:21 -04:00
Jeremiah Lowin
60c6441d7b Fix formatting per pre-commit hooks
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-19 18:22:02 -04:00
Jeremiah Lowin
370c44b745
Merge branch 'main' into dev-20250619-173841 2025-06-19 18:21:18 -04:00
Jeremiah Lowin
942fd5c13e Add session_id property to Context for session-based data sharing
Exposes MCP session ID from HTTP headers to enable Redis-based data sharing
between tools. Returns None for stdio/memory transports as expected.

Fixes #875, addresses python-sdk#986, python-sdk#942, python-sdk#485

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-19 18:16:34 -04:00
Jeremiah Lowin
085c5b765b Update docs and tests 2025-06-19 17:06:54 -04:00
Jeremiah Lowin
0beb79d11a Minor updates 2025-06-19 15:28:55 -04:00