modelcontextprotocol / modelcontextprotocol/typescript-sdk
Convert tool/prompt schemas eagerly at register time instead of on tools/list
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 13.4k
- Forks
- 2.2k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 4
Description
Currently standardSchemaToJsonSchema() is called lazily inside the tools/list request handler (mcp.ts:145, 153), re-converting every tool's schema on every list request.
Moving this to registerTool() / registerPrompt() time and caching the JSON Schema result on RegisteredTool/RegisteredPrompt would:
- Surface schema errors (e.g. cycle detection from #1563) at dev time when the tool is registered, not at runtime when a client first calls
tools/list - Avoid re-converting identical schemas on every
tools/listcall - Match Go SDK and fastmcp, which both process schemas at registration time
Scope: registerTool, registerPrompt, the tools/list and prompts/list handlers, and RegisteredTool.update() / RegisteredPrompt.update() (need to re-convert when schema changes).
Related: #1563 (where this came up)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in mcp.ts at the tools/list handler around lines 145 and 153, then trace registerTool(), registerPrompt(), RegisteredTool.update(), and RegisteredPrompt.update(). Move schema conversion to registration and update paths while preserving the list responses and ensuring schema changes are re-converted. Done means schemas are not re-converted on each tools/list or prompts/list request and conversion errors surface during registration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100