Commit graph

118 commits

Author SHA1 Message Date
Jeremiah Lowin
5d57f5bd0f Use claude-sonnet-4-5-20250929 model name 2025-12-09 19:29:02 -05:00
Jeremiah Lowin
7e02fa29b2 Add Anthropic sampling handler and consolidate sampling examples
- Add AnthropicSamplingHandler in server/sampling/anthropic.py
- Consolidate all sampling examples into examples/sampling/ with rich output
- Examples: text.py, structured_output.py, tool_use.py, server_fallback.py
- Add anthropic optional dependency
2025-12-09 15:04:35 -05:00
Jeremiah Lowin
b544cddca7 Merge main into sampling-tools-sep-1577 2025-12-04 22:23:54 -05:00
Jeremiah Lowin
5c0f05511b Remove @sampling_tool decorator - pass functions directly to sample()
Functions passed to ctx.sample(tools=[...]) are now auto-converted
via SamplingTool.from_function(). Users can still use that method
directly for custom name/description overrides.
2025-12-04 22:19:27 -05:00
Chris Guidry
66aaf420c9
[2.14] SEP-1686 tasks (#2378)
* Implement MCP background tasks (SEP-1686) using Docket

Adds support for background task execution via the MCP task protocol,
powered by Docket for task queue management.

- Tools, resources, and prompts can be marked with `task=True` to run async
- Progress dependency for tracking task progress
- CurrentDocket and CurrentWorker dependencies for advanced use cases
- Client API with `.call_tool(..., task=True)` returns task handles
- Task status notifications via subscriptions
- CLI worker command for distributed task processing

Configuration via environment:
- FASTMCP_ENABLE_DOCKET=true
- FASTMCP_ENABLE_TASKS=true
- FASTMCP_DOCKET_URL=redis://... (or memory:// for single-process)

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix tasks example import (TaskStatusResponse → GetTaskResult)

The example was using a non-existent TaskStatusResponse type.
Updated to use mcp.types.GetTaskResult which is what the
on_status_change callback actually receives.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix env var name in Docket error messages

The error messages referenced FASTMCP_EXPERIMENTAL_ENABLE_DOCKET but the
actual setting is FASTMCP_ENABLE_DOCKET.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove deprecated code re-added from pre-#2329 branch

- Remove ExtendedEnvSettingsSource (FASTMCP_SERVER_ prefix support)
- Remove dependencies parameter from FastMCP.__init__

* Replace fakeredis git pin with PyPI release

* Remove redundant fakeredis dev dep (pulled via pydocket)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-12-04 20:10:35 -05:00
Jeremiah Lowin
0d8679c0ad SEP-1577: Sampling with tools
- Add tools and result_type parameters to ctx.sample()
- Update OpenAI handler for tool content types
- Client advertises sampling.tools capability by default
- Collect tool results into single message with list content
2025-12-04 12:41:19 -05:00
Jeremiah Lowin
9cade6c8c8
Fix RFC 8414 path-aware authorization server metadata discovery (#2533)
* Fix RFC 8414 path-aware authorization server metadata discovery

Override get_well_known_routes() in OAuthProvider to rewrite the
authorization server metadata route to be path-aware based on issuer_url,
matching how protected resource metadata already works.

Closes #2527

* Update readme
2025-12-03 19:16:59 -05:00
Jeremiah Lowin
ee5f465a82
2.14 deprecation removals (#2329)
* Initialize 2.14 deprecation removal branch

* Remove deprecated FASTMCP_SERVER_ environment variable prefix (#2330)

* Remove deprecated Context.get_http_request method (#2332)

* Remove fastmcp.Image top-level import (deprecated 2.8.1) (#2334)

* Remove test warnings (#2331)

* Create new branch and fix issue

* Remove deprecated client parameter from FastMCPProxy (#2333)

* Remove deprecated run_streamable_http_async method (#2338)

* Remove deprecated sse_app method (#2337)

* Remove deprecated run_sse_async method (#2335)

* Remove deprecated run_sse_async method

* Update CLI and tests to use run_http_async(transport="sse")

- Change CLI to call run_http_async with transport="sse" instead of run_sse_async
- Update test to mock run_http_async with create=True for v1 servers

* Revert CLI changes - v1 servers do have run_sse_async

- Keep CLI calling run_sse_async() for v1 compatibility
- Update test to mock run_sse_async (which exists on v1)

* Remove unnecessary type ignore for run_sse_async

Method exists on v1 FastMCP class, no type error

* Remove unused imports after test deletion

* Remove deprecated streamable_http_app method (#2336)

* Remove deprecated dependencies parameter from FastMCP constructor (#2340)

* Remove output_schema=False support (deprecated 2.11.4) (#2339)

* Remove deprecated client parameter from FastMCPProxy (#2333)

* Delete deprecated test_output_schema_false.py

Tests functionality that has been removed

* Remove deprecated BearerAuthProvider module (#2341)

* Remove resource_prefix_format="protocol" support (deprecated 2.4.0) (#2342)

* Remove resource_prefix_format="protocol" support (fixes #2195)

Removes deprecated protocol format (prefix+resource://path) and keeps only
path format (resource://prefix/path). Since only one format remains:

- Removed resource_prefix_format from settings, FastMCP.__init__, and helpers
- Simplified add_resource_prefix, remove_resource_prefix, has_resource_prefix
- Removed MountedServer.resource_prefix_format field
- Deleted tests for protocol format

All resource prefixes now use path format exclusively.

* Clean up resource_prefix_format references

- Remove from test files
- Update documentation to remove protocol format section
- Move custom HTTP routes note to mounting section
- Remove resource_prefix_format from settings docs

* Use inline version note instead of badge for prefix format

* Remove obsolete test functions and update docs

- Delete test functions that no longer assert anything
- Remove proxy.mdx reference to deleted prefix format section

* Format error messages per ruff

* Remove from_client classmethod (deprecated 2.8.0) (#2343)

* Remove deprecated from_client classmethod (fixes #2192)

* Remove unused Client import

* Remove add_resource_fn method (deprecated 2.7.0) (#2345)

* Update SDK

* Add missing imports for exclude_args deprecation warning
2025-12-01 14:11:00 -05:00
Jeremiah Lowin
83085c3cd3
Fix version badges for icons and website_url; add Discord example (#2509)
* Fix version badges and remove redundant badges from Discord doc

* Add Discord OAuth example
2025-12-01 13:39:43 -05:00
Akshay Parihar
a57a155c2e
Scalekit provider updates (#2413)
* sk-provider updates - aud not enforce, scopes enforce if present

* updating env_prefix, adding debug logs

* updating docs

* ruff formatting

* not changing prefix for backward compatiblity

* backward compatibility changes

* give more preference to base_url than mcp_url if both passed

* updating docs

* refactor

* updating example server

* updating readme of example

* updating docs

* updating tests to reflect what should ideally go in the parameter
2025-11-22 12:22:13 -05:00
William Easton
8e0c6c8685
docs: clarify pytest-asyncio dependency and asyncio mode configuration (#2399)
* docs: clarify pytest-asyncio dependency and asyncio mode configuration

Added a Prerequisites section to the testing documentation explaining:
- pytest-asyncio is required for async test functions and fixtures
- Recommended configuration: asyncio_mode = 'auto' in pyproject.toml
- This eliminates need for @pytest.mark.asyncio decorators

Resolves #2372

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

* feat: add testing_demo example with comprehensive test suite

Add a standalone example project demonstrating FastMCP testing patterns:
- Tools, resources, and prompts with full test coverage
- pytest-asyncio configuration in pyproject.toml
- 18 passing tests showing async fixtures, parametrized tests, and more
- Documentation explaining testing best practices

Co-authored-by: William Easton <strawgate@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>
2025-11-15 10:34:29 -05:00
Jeremiah Lowin
bbf3050ba7
Improve ToolResult and structured output documentation (#2349)
- Restructured confusing sections: 'Object-like Results' → 'Dictionaries and Objects', 'Non-object Results' → 'Primitives and Collections', 'Complex Type Example' → 'Typed Models'
- Simplified CodeGroup examples to show Tool Definition + MCP Result instead of 3-4 confusing tabs
- Split Primitives/Collections into separate CodeGroups for clarity
- Renamed 'Full Control with ToolResult' → 'ToolResult and Metadata' for better TOC visibility
- Flattened ToolResult documentation with inline field descriptions instead of nested headings
- Added version badge for ToolResult meta field (2.13.1)
- Added clarification that ToolResult meta is separate from @mcp.tool meta
- Improved example server with realistic metadata (execution time, character/word counts)
- Fixed code formatting (multi-line objects, trailing commas)
2025-11-02 17:07:48 -05:00
Brandon Shar
c18782f02b
Add meta support to ToolResult (#2283)
* Add meta to ToolResult

* add this at the client level and test the full integration

* add example

* slipped through linting somehow

---------

Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-11-02 16:46:52 -05:00
Jeremiah Lowin
ba47db9b8c
Fix Azure scope validation (#2269)
* 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
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
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
zzstoatzz
29b0330882 example: update server init usage 2025-10-21 19:34:08 -05:00
Jeremiah Lowin
e7cde97e5b
Docs (#2145)
* Update fonts + styling

* Update docs.json

* Update welcome.mdx
2025-10-19 20:26:08 -04:00
Jeremiah Lowin
9e78d755c2
Support custom server name, icons, and link in OAuth Proxy consent page (#2135)
* Implement icon support in fastmcp

* Fix icon feature tests

- Update snapshot for ResourceTemplate to include icons field
- Remove OAuth mounting tests (belong to PR #2119, not this feature)

* Update docs

* Customize consent screen

* Use server website link if available

* Anchor link shouldnt have trailing slash

* Remove 'a FastMCP server named' from consent page message

* Update docs
2025-10-18 11:49:26 -04:00
Jeremiah Lowin
91af3cd2ae
Internal refactor of MCP handlers (#2005) 2025-10-05 08:45:10 -04:00
Jeremiah Lowin
66221ed3ec
Remove redirect path for authkit example (#1938) 2025-09-27 12:01:41 -04:00
Jeremiah Lowin
7646eadeb0
Add authkit example (#1935) 2025-09-26 18:33:08 -04:00
Akshay Parihar
7bcf8b562c
Add Scalekit Provider for Enterprise Authentication (#1927)
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Ravi Madabhushi <ravi.madabhushi@scalekit.com>
Co-authored-by: Ravi Madabhushi <innovativeravi@gmail.com>
Co-authored-by: saif-at-scalekit <saif.shaik@scalekit.com>
2025-09-26 16:58:03 -04:00
Stephan Eberle
5486b5a3b9
Add AWS Cognito OAuth Provider for Enterprise Authentication (#1873)
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-09-25 11:08:45 -04:00
nate nowack
7770e3a6bc
remove lockfile smart_home example (#1892)
Co-authored-by: Claude <noreply@anthropic.com>
2025-09-22 20:07:19 -04:00
Jeremiah Lowin
d36ea42b92
Fix OAuth resource URL handling and WWW-Authenticate header (#1706) 2025-09-02 15:14:05 -04:00
Jeremiah Lowin
05b611b68d
Make openai depedency optional (#1701) 2025-09-02 15:13:37 -04:00
Jeremiah Lowin
8c678b552b
Add resource_server_url parameter to OAuth proxy providers (#1682) 2025-08-30 08:33:13 -04:00
Jeremiah Lowin
6d46192659
Internal refactor: fastmcp config to mcp server config (#1672) 2025-08-29 21:37:39 -04:00
Jeremiah Lowin
1f3f82d245
Implement typed source system for FastMCP configuration (#1607) 2025-08-24 16:32:37 -04:00
Jeremiah Lowin
b34519c356
Update schema path (#1595) 2025-08-23 09:47:58 -04:00
William Easton
d32a2b953e
Fallback to a Completions API when Sampling is not available (#1145) 2025-08-21 07:49:29 -04:00
Jeremiah Lowin
c3d1176a69
Add WorkOS and Azure OAuth providers (#1550) 2025-08-20 16:22:03 -04:00
zzstoatzz
04efab4257 fix: auto-detect URLs in ATProto posts for clickable links
The ATProto MCP server now properly handles URLs in posts by:
- Auto-detecting plain URLs in text and creating facets to make them clickable
- Supporting rich text links with custom anchor text
- Preventing overlap between auto-detected and explicitly provided links

This ensures all URLs are clickable on Bluesky, whether they're plain URLs
in text or rich text links with custom anchors.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 11:31:56 -05:00
zzstoatzz
d3f120a059 undo unnecessary client change 2025-08-20 00:54:09 -05:00
zzstoatzz
5fd8ba1aa4 reauth client 2025-08-20 00:36:16 -05:00
Jeremiah Lowin
2d3d5392f1
feat: introduce fastmcp.json configuration system (#1517) 2025-08-19 16:06:04 -04:00
Jeremiah Lowin
ec015de3b0
Add OAuth proxy that allows authentication with social IDPs without DCR support (#1434) 2025-08-18 13:39:58 -04:00
Jeremiah Lowin
45c4ceb1bd
Update environment note (#1075)
* Update environment note

* Update memory.py
2025-07-07 13:44:19 -04:00
Chanwoo Noh
7a1e332aae fix: update mount_example.py for current fastmcp API
- Update mount() calls to use keyword arguments (server, prefix)
- Replace private API access with public async methods (get_tools, get_resources)
- Fix resource URI handling to use URL parsing instead of string prefixes
- Update resource access to use _mcp_read_resource with proper URI format
- Add urllib.parse import for URL parsing functionality

The mounting API and resource handling changed in recent fastmcp versions,
breaking the mount_example.py functionality. This update ensures the example
works correctly with fastmcp v2.9.0.

Tested on: fastmcp v2.9.0
2025-06-26 14:44:51 +09:00
zzstoatzz
6d19f4369f i dont think i need that 2025-06-23 12:43:42 -05:00
zzstoatzz
560c347949 Add delay between thread posts to ensure proper indexing
- Add 0.5s sleep between posts in create_thread
- Prevents 'Parent post not found' errors
- Ensures each post is indexed before creating replies

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-23 12:40:20 -05:00
zzstoatzz
5b10fd2107 thread 2025-06-23 12:38:11 -05:00
zzstoatzz
7b14a00b4e remove uv source in example 2025-06-23 02:31:26 -05:00
zzstoatzz
e42f9fec7f fix path in atproto example pyproject 2025-06-23 02:27:08 -05:00
zzstoatzz
dc52874300 update url for main 2025-06-22 23:48:25 -05:00
zzstoatzz
2701de8e7b Move search from resource to tool
- Search is an action with parameters, not a resource
- Resources are for fetching by URI (profile, timeline, notifications)
- Tools are for actions (post, search, follow, like, repost)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-22 23:28:29 -05:00
zzstoatzz
a5e2cf46fd ope 2025-06-22 23:16:22 -05:00