Skip to content

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

Description

@felixweinberger

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 fix: inline local $ref in tool inputSchema for LLM consumption #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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Nice to haves, rare edge casesenhancementRequest for a new feature that's not currently supportedneeds decisionIssue is actionable, needs maintainer decision on whether to implement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions