modelcontextprotocol / modelcontextprotocol/typescript-sdk

Convert tool/prompt schemas eagerly at register time instead of on tools/list

Open
#1,847 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement needs decision P3
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/list call
  • 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.