Commit graph

110 commits

Author SHA1 Message Date
Shuying
c428a08fea
fix: preserve valid servers during CLI discovery (#4714)
Co-authored-by: Shuying <zsy@u.northwestern.edu>
2026-08-02 09:42:26 -04:00
Jeremiah Lowin
d6b9daecb1
Read CLI-scanned MCP config files as UTF-8 explicitly (#4690) 2026-07-28 08:12:17 -04:00
Jeremiah Lowin
19c5c507cc
Address review feedback on SEP-2663 tasks
- Client task support is opt-in via importing fastmcp_tasks (drop the core
  auto-load of companion packages); a plain Client never advertises tasks.
- A worker restores the submitting caller's auth token and headers from the
  task snapshot into the standard ambient context, so get_access_token() /
  get_http_headers() work in a distributed worker with no new core hooks.
- worker_cli validates the loaded extension's resolved backend, not env defaults,
  so a constructor-configured Redis worker starts.
- Thread the per-call read timeout through task polling; bound ToolTask.wait by
  its deadline; set_elicitation_callback rebuilds internal extensions so a
  later-set handler answers in-task input.
- README imports TaskConfig from fastmcp.utilities.tasks.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-22 19:14:16 -04:00
Jeremiah Lowin
5fa2883670
Implement SEP-2663 tasks extension: TasksExtension, poll-based task lifecycle
TasksExtension serves io.modelcontextprotocol/tasks on the extension API:
a decide-and-task tools/call interceptor (era-gated to modern connections),
tasks/get with inlined results and inputRequests, tasks/update delivering
poll-based in-task elicitation, tasks/cancel, durable creation, and
auth-scoped task isolation. Wire models validate against the vendored
ext-tasks schema. Worker-side Context hooks are refcounted so sibling
servers cannot strand each other's workers.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-21 23:00:38 -04:00
Jeremiah Lowin
6fce4e538f
Move task subsystem to fastmcp-tasks package, disconnect SEP-1686 wire from core
Engine modules (keys, context snapshot, docket lifespan, worker CLI,
client handles) move intact; SEP-1686 wire modules park in _legacy_wire
for adaptation to SEP-2663. Core keeps task=True declaration on tools
only and raises at serve time until the tasks extension is registered.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-21 21:51:45 -04:00
Jeremiah Lowin
3522a98766
Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
fengguodong
0d8844d5a7
Reject empty env var keys (#4410) 2026-06-29 09:42:06 -04:00
Jeremiah Lowin
a1dd8b12e1
Fix dev apps launch escaping (#4399) 2026-06-27 12:18:36 -04:00
Jeremiah Lowin
a13e48ea6f
feat(remote): add --verify flag for TLS certificate verification (#4369) 2026-06-24 12:09:22 -04:00
Jeremiah Lowin
70013c5a91
Add fastmcp-remote bridge package (#4208) 2026-05-23 10:04:21 -04:00
yuyua9
dbf5ee24be
fix(cli): forward stateless flag in uv run path (#4177)
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2026-05-20 12:22:45 -04:00
itaru2622
7fddab52a9
feat: new options --host and --no-log-panel | --log-panel to cli dev apps (#4123) 2026-05-20 09:37:32 -04:00
itaru2622
310314cf14
fix: cli option --no-banner is NOT passed to cli but server-spec in-correctly when cli --reload option is specified. (#4083) 2026-05-09 14:57:42 -04:00
Jeremiah Lowin
64fbc52e1d
fix: skip stdio subprocess test on Windows CI (#3966)
Co-authored-by: Marvin Context Protocol <41898282+Marvin Context Protocol@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>
2026-04-18 10:30:03 -04:00
Jeremiah Lowin
c397e68d39
Update ty ignore comments for 0.0.25 compatibility (#3614) 2026-03-24 20:26:26 -04:00
Jeremiah Lowin
b2d4cc90e5
fix: validate server names in install commands (#3522)
* fix: validate server names in install commands

* Scope validation to shell-backed install paths only
2026-03-15 14:54:24 -04:00
Sascha Buehrle
dc7ae0bad1
fix: remove hardcoded version from CLI help text (#3456)
Changed 'FastMCP 2.0' to 'FastMCP' per maintainer feedback.
Dynamic version via fastmcp.__version__ still available via version flag.
2026-03-14 12:07:24 -04:00
Jeremiah Lowin
08f590fa9e
Sanitize untrusted output in fastmcp list and fastmcp call (#3409)
* Sanitize untrusted CLI client output

🤖 Generated with GPT-5.2-Codex

* Fix ruff format violations
2026-03-07 12:31:46 -05:00
Jeremiah Lowin
dcaeef0f3d
Handle missing npx.cmd fallback on Windows 🤖 Generated with GPT-5.2-Codex (#3416) 2026-03-07 11:40:57 -05:00
Jeremiah Lowin
fadb630142
Validate workspace path is a directory in cursor install (#3426) (#3435) 2026-03-07 11:40:33 -05:00
Sumanshu Nankana
34d848b16a
feat: add --config-path flag to claude-desktop install command (#3380)
* feat: add --config-path flag to claude-desktop install command

* feat: add --config-path flag to claude-desktop install command

* docs: add --config-path option to install-mcp documentation

* fix: show specific error message when provided --config-path does not exist
2026-03-04 15:30:59 -05:00
dgenio
9d635bc026 Address maintainer review: reload support, type annotation, test imports 2026-03-01 13:29:54 -05:00
dgenio
52144ce20b Apply ruff formatting to test file 2026-03-01 13:29:54 -05:00
dgenio
2b28cd2a88 Add integration tests for module mode in run and inspector 2026-03-01 13:29:54 -05:00
dgenio
173b93a4c3 Use bare python for module mode when uv wraps the command 2026-03-01 13:29:54 -05:00
dgenio
7a582ff5a0 Add -m/--module flag to fastmcp run and dev inspector 2026-03-01 13:29:54 -05:00
Jeremiah Lowin
618195c065
Move fastmcp dev to fastmcp dev inspector 2026-02-13 22:42:38 -05:00
Jeremiah Lowin
f7cdd20a42
generate-cli: auto-generate SKILL.md agent skill (#3115)
* generate-cli: auto-generate SKILL.md alongside CLI script

generate-cli now produces a SKILL.md agent skill file next to the CLI
script, documenting every tool's exact invocation syntax, parameter
flags, and types. Agents can use the CLI immediately without discovery.

* Use uv run --with fastmcp in generated SKILL.md invocations

* Fix skill generation issues from review

- Escape pipe chars in union type labels so markdown tables render
- Boolean params omit <value> placeholder in example invocations
- Quote YAML frontmatter values to handle special chars in names
- Match cyclopts camelCase→snake_case in flag derivation
- Use four-backtick fence for nested code block in docs

* Replace --skill/--no-skill with just --no-skill

* Escape quotes in YAML frontmatter description

* Strip newlines from param descriptions in skill table rows

* Detect boolean union types for flag placeholder
2026-02-08 17:09:28 -05:00
Jeremiah Lowin
880d835ccc
Add CIMD (Client ID Metadata Document) support for OAuth (#2871) 2026-02-06 13:44:52 -05:00
Jeremiah Lowin
4262cfc16a
Add fastmcp generate-cli command (#3065)
* Add `fastmcp generate-cli` command

Connects to any MCP server, reads its tool/resource/prompt schemas,
and writes a standalone Python CLI script with typed subcommands.

* docs: add generate-cli documentation

* docs: add generate-cli documentation; skip Windows executable test

* fix: address PR review feedback

- Sanitize tool and parameter names to valid Python identifiers
- Replace bare except Exception with specific exception types
- Escape server name in generated string literals
- Handle trailing colon edge case in _derive_server_name
- Clarify in docs that generated CLI is a client, not a bundled server

* Fix string escaping issues in generate-cli

- Use single-quoted docstrings to avoid triple-quote escaping issues
- Escape quotes in app_name derived from server_name
- Add tests for descriptions with quotes and server names with quotes

Addresses CodeRabbit review comments about insufficient escaping.

* Implement smart parameter handling for generate-cli

- Simple types (str, int, float, bool): Direct typed flags
- Arrays of simple types (list[str], list[int]): Repeatable flags via cyclopts
- Complex types (objects, nested arrays): Accept JSON strings with parsing
- JSON schema shown in help text for complex parameters
- Proper escaping of newlines and quotes in help text
- Filter out None and empty list defaults when calling tools

This gives typed, discoverable CLIs for common cases while handling
complex schemas via JSON input.

* Update generate-cli docs to explain smart parameter handling

- Document simple types as direct typed flags
- Document arrays of simple types as repeatable flags
- Document complex types as JSON strings with schema in help
- Add examples showing all three patterns

* Fix Codex review issues in generate-cli

High priority fixes:
- Complex type defaults: Serialize dict/list defaults to JSON strings
- List params: Preserve help metadata with Annotated wrapper
- Name collisions: Detect and error on sanitized name conflicts
- JSON parsing: Use isinstance check for safety with defaults

Added tests for:
- Complex types with default values
- Parameter name collision detection
- Updated existing tests to match new format

* Use pydantic_core.to_json for consistency

- Generator now uses pydantic_core.to_json() instead of json.dumps()
- Consistent with rest of fastmcp codebase
- Generated CLI still uses plain json module (standalone script)

* Move local imports to module level in generate-cli

* Handle union item types and Python keyword collisions in generate-cli
2026-02-03 21:08:51 -05:00
Jeremiah Lowin
186604a8a2
Merge branch 'main' into claude/issue-3049-20260131-2232 2026-02-01 21:29:57 -05:00
Jeremiah Lowin
adf21ac630
Add fastmcp discover and name-based server resolution (#3055) 2026-02-01 21:27:22 -05:00
Jeremiah Lowin
bd37763e98
Add fastmcp list and fastmcp call CLI commands (#3054) 2026-02-01 18:30:14 -05:00
claude[bot]
cd085412d1 Mock network call in test_version_command_execution
Fixes #3049 by mocking check_for_newer_version to prevent real network
calls to PyPI during tests, which was causing timeouts on Windows.

Co-authored-by: Bill Easton <strawgate@users.noreply.github.com>
2026-01-31 22:35:43 +00:00
Jeremiah Lowin
1bbbee37a6
feat: add fastmcp install goose command (#3040) 2026-01-31 10:53:24 -05:00
Jeremiah Lowin
003df5b22b
Add fastmcp install stdio command (#3032) 2026-01-29 22:19:15 -05:00
Jeremiah Lowin
d9cbc06ff1
feat: expand --reload to watch frontend file types (#3028) 2026-01-29 09:23:55 -05:00
Jeremiah Lowin
c3111a8978
Unify discovery API: deduplicate at protocol layer only (#2919) 2026-01-18 21:01:53 -05:00
Jeremiah Lowin
2b6a0faf1c
Add loq file size limits and clean up type ignores (#2859) 2026-01-13 07:29:12 -05:00
Jeremiah Lowin
42dcb8918d
Add --reload flag for auto-restart on file changes (#2816) 2026-01-09 08:44:27 -05:00
Jeremiah Lowin
9c83482f4c
Make FASTMCP_SHOW_SERVER_BANNER apply to all server startup methods (#2771) 2025-12-29 08:29:15 -05:00
Jeremiah Lowin
a39ab0734e
Update classes to inherit from FastMCPBaseModel instead of BaseModel (#2739) 2025-12-26 08:33:23 -05:00
Jeremiah Lowin
125f79ff39
Consolidate get_* and _list_* methods into single API (#2719) 2025-12-24 22:26:52 -05:00
Jeremiah Lowin
049bd22827
Replace type: ignore[attr-defined] with isinstance assertions in tests (#2665)
* Replace type: ignore[attr-defined] with isinstance assertions in tests

* Fix isinstance assertions in failing tests

- Fix enum test to check for ResponseEnum instead of str
- Fix binary resource test to check for BlobResourceContents instead of TextResourceContents
- Fix Root type tests to check attributes directly instead of isinstance checks

* Fix type errors without using type: ignore

- Remove execution methods from TransformingProvider (only handles transformations)
- Add execution methods to base Provider class with default implementations
- Fix type narrowing in tests using cast() instead of type: ignore
- Fix PromptResult type handling in prompt render tests
- Fix type narrowing in middleware test for arguments and structured_content
2025-12-21 16:37:20 -05:00
Chris Guidry
47d3044b06 Remove enable_docket setting; Docket is now always on
Docket provides background task execution and is now always available
for all FastMCP servers. Only `enable_tasks` remains to control the
SEP-1686 task protocol support.

Changes:
- Remove `enable_docket` setting and related validation
- Docket/Worker lifecycle is always active in server lifespan
- CurrentDocket and CurrentWorker dependencies work without config
- Add server readiness signaling via `_started` event
- Fix test timing issues with proper port probing

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 11:40:04 -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
80d10d23f4
Fix: URL-encode server name in Cursor deeplinks (#2369)
Server names with special characters (&, ?, #, etc.) were creating
malformed deeplink URLs. Now properly percent-encoded.
2025-11-04 11:26:57 -05:00
Cole Murray
0e97a261cf
Security: Validate Cursor deeplink URLs and use safer Windows API (#2348)
* 🤖 Security: Validate Cursor deeplink URLs and replace cmd.exe on Windows

- Add URL scheme validation to reject non-cursor:// URLs
- Replace subprocess cmd.exe call with os.startfile() on Windows
- Add tests for scheme validation and error handling

* 🤖 Fix tests for cross-platform deeplink validation
2025-11-02 19:49:07 -05:00
Jeremiah Lowin
3321644ad3
Replace subprocess tests with in-process async servers (#2006)
* Use anyio as testing backend

* Remove asyncio markers

* Update streamable http tests

* Replace all subprocess tests

* Replace anyio task groups with asyncio context managers in tests

- Convert run_server_async from anyio task group pattern to asyncio.create_task with async context manager
- Remove task_group fixture from conftest
- Update all test fixtures to use async with run_server_async pattern
- Remove TaskGroup imports from all test files
- Tests now work with pytest-asyncio instead of pytest-anyio

* Update test_github_provider_integration.py
2025-10-19 10:47:54 -04:00
Jeremiah Lowin
5f8461b7f0
Remove shell=True from Windows subprocess calls (#2091) 2025-10-14 12:30:46 -07:00