MCPServer: public hooks for tool input schemas, capabilities and handler removal
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start with MCPServer in mcp.server.mcpserver and Server in mcp.server.lowlevel, then inspect ServerSession and the existing middleware hook. Check the guard tests mentioned in the issue and run the relevant tests before trying a branch. Done means the four requested hooks or public APIs are available and tested, including stable connection identity.
由索引模型根据 Issue 内容生成。
描述
Description
We build an MCP server framework on mcp 2.x's MCPServer (mcp.server.mcpserver). It owns its own tool registry, so it overrides list_tools and call_tool, and it needs four more things the SDK only offers through private attributes. Each one ties us to a single 2.x minor, because a rename in a minor release silently changes what our users' clients see.
-
Tool input schemas for
Mcp-Paramheader validation. The low-levelServertakesget_tool_input_schema, butMCPServeralways passes its own_tool_input_schema, which reads_tool_manager. A subclass that answerstools/listandtools/callitself has to override the private_tool_input_schema(or fill_tool_manager._toolswith hand-builtToolobjects). Ask: acceptget_tool_input_schema=in theMCPServerconstructor, or make the method a documented, overridable public one. -
Adjusting advertised capabilities. We must report
capabilities.tools.listChanged: false(we never sendnotifications/tools/list_changed) and declare an extension only to some callers. Today that means reachingMCPServer._lowlevel_serverand replacingget_capabilitieson the instance. Ask: a public way to post-processServerCapabilitiesper request (a constructor callback such ascapabilities=lambda ctx, caps: caps), and a public accessor for the low-level server (MCPServer.lowlevel). -
Removing a default handler.
MCPServerregistersprompts/list,prompts/getand the resource handlers by default, and capabilities are derived from which handlers exist.Serverhasadd_request_handlerandget_request_handlerbut noremove_request_handler, so we pop from the private_request_handlers. Ask:Server.remove_request_handler(method), or constructor flags to leave prompts and resources out. -
A stable identity for a 2025-era connection. 2.x builds a
ServerSessionper request; the only stable identity of a client connection is the privateServerSession._connection. We key per-connection state (an "active context" a client enters and leaves) on it. Ask: a public, hashable connection identity on the request context (for examplectx.connection_id), documented as stable for the life of a 2025-era connection.
MCPServer.middleware (documented as provisional) already covers the one other hook we needed. We have guard tests for each of the above and can test a branch.
References
- Observed on
mcp2.3.0 and 2.4.0 (mcp.server.mcpserver.MCPServer,mcp.server.lowlevel.Server,ServerSession).
- 主要语言
- Python
- 星标
- 25k
- 派生
- 4.2k
- 平均合并
- 10 分钟
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/python-sdk 的其他 Issue
-
v2
难度 1/5 1 小时以内 新手友好度 86/100
modelcontextprotocol/python-sdk#3978 · 2 条评论 ·
维护者通常 1 天内回复
-
Client serves cached tools after its context exits with an exception可能已有人在做 @jonxsong 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
modelcontextprotocol/python-sdk#3968 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
modelcontextprotocol/python-sdk#3957 ·
维护者通常 1 天内回复
-
v2
难度 1/5 1 小时以内 新手友好度 91/100
modelcontextprotocol/python-sdk#3934 · 2 条评论 ·
维护者通常 1 天内回复
-
bug v1
难度 2/5 1-3 小时 新手友好度 79/100
modelcontextprotocol/python-sdk#3929 · 2 条评论 ·
维护者通常 1 天内回复
查看 modelcontextprotocol/python-sdk 的全部 Issue
相似的 Issue
-
auto-reported bug
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
-
backend bug
难度 2/5 1-3 小时 新手友好度 86/100
nolte/kamerplanter#3193 ·
维护者通常 1 天内回复
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwise可能已有人在做 @abdulwaarith0 今天认领。 未关闭needs-triage
难度 2/5 1-3 小时 新手友好度 84/100
MakazhanAlpamys/Soup#3690 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复