modelcontextprotocol / modelcontextprotocol/python-sdk

Design: future of `dependencies` parameter on MCPServer

未關閉
#2,354 2 則留言 4 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

enhancement needs decision P2 v2
主要語言
Python
星號
24.3k
分支
4k
平均合併
1 天 1 小時
30 天內合併 PR
31

描述

Context

PR #1877 removed the dependencies parameter from FastMCP (now MCPServer). After investigation, we're restoring it for now because removing it without a replacement breaks high-profile users and leaves a functionality gap. This issue tracks the design decision for what to do long-term.

What dependencies does

It's a list of pip/uv package names declared on the server instance:

mcp = MCPServer("Screenshot Demo", dependencies=["pyautogui", "Pillow"])

The only consumer is the mcp CLI — mcp dev and mcp install read server.dependencies via hasattr/getattr and convert them to uv run --with <pkg> flags when launching the server or writing Claude Desktop config. See https://github.com/modelcontextprotocol/python-sdk/blob/7ba4fb881d85406f44a5af8169fb7200fa7c8e49/src/mcp/cli/cli.py#L261-L262 and https://github.com/modelcontextprotocol/python-sdk/blob/7ba4fb881d85406f44a5af8169fb7200fa7c8e49/src/mcp/cli/cli.py#L451-L453.

It has no relationship to the MCP protocol or the low-level Server class — it's purely a Python/uv packaging convenience that originated in jlowin's original FastMCP.

Why we can't just remove it

Real-world usage is significant (~772 files on GitHub, ~95+ repos):

  • awslabs/mcp (8.5k★) — 47 server files use it as their standard template
  • mindsdb/mindsdb (38.8k★) — uses it
  • redis/mcp-redis (461★), volcengine/mcp-server, camel-ai/camel, plus ~15–20 community servers

When jlowin's fastmcp package removed the same parameter, it caused 8+ breakage issues across awslabs/mcp, zotero-mcp, panther-labs, ClickHouse — all TypeError: unexpected keyword argument 'dependencies'.

The replacement gap

The v2 examples were migrated to PEP 723 inline script metadata:

# /// script
# dependencies = ["pyautogui", "Pillow"]
# ///

But this does not currently work with mcp install / mcp dev. Those commands generate uv run --with mcp[cli] mcp run server.pyuv only parses PEP 723 when the script is the direct target, not when it's an argument to another command. So the feature was removed without a working replacement.

Options (Claude's ideas)

A. Keep dependencies, do nothing

Simplest. Works. Mixes packaging metadata into server code, which is architecturally questionable.

B. Deprecate → PEP 723, teach the CLI to parse it

Add a DeprecationWarning to the parameter. Update mcp dev/mcp install to parse # /// script blocks from the target file and convert dependencies = [...] to --with flags. PEP 723 has a ~15-line reference parser in the spec. Remove the parameter in a later release.

C. Follow FastMCP 2.0's lead: config file

jlowin's FastMCP 2.0 replaced dependencies= with a fastmcp.json config file (source/environment/deployment sections), deprecated for ~3.5 months, then removed. They also expanded install to 7 targets (claude-desktop, claude-code, cursor, gemini-cli, goose, mcp-json, stdio). This is the richest solution but the most work, and overlaps with what FastMCP 2.0 already provides.

D. Deprecate → point users at FastMCP 2.0

If the official SDK's CLI is meant to stay minimal, deprecate dependencies and mcp install/mcp dev together, pointing users to fastmcp for deployment tooling.

AI Disclaimer

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 src/mcp/cli/cli.py 中所參照的 mcp dev 和 mcp install 位置的相依性處理開始,接著追蹤 MCPServer 如何公開相依性。將這些路徑與 PEP 723 範例及列出的設定替代方案進行比較。當形成一項有文件記錄的長期決策,並明確規定 CLI 和 MCPServer 受影響的行為時,即視為完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
backend-api-design, cli
Issue 類型
重構
難度
5/5
預估耗時
一週以上
活躍度
冷清
描述清晰度
需要釐清
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。