Skip to content

inputSchema is undefined in server.tool, causing MCP Client issuesΒ #9

Closed
@bohdan-romanchenko

Description

@bohdan-romanchenko

When registering a tool using server.tool, like in the example below:

server.tool(
  "get-neme",
  {
    slug: z.string().min(1).describe("The slug of the neme"),
  } as ToolAnnotations,
  async ({ slug }) => {
    return {
      content: [{ type: "text", text: `${slug}` }],
    };
  }
);

The returned object should conform to the RegisteredTool type, which includes the inputSchema. However, in practice, inputSchema is always undefined.
This causes issues with the MCP Client, specifically the MCP Inspector, which relies on inputSchema to display and send input arguments. Without it, tools are effectively unusable via the default MCP Client interface.

Current Workaround

The only way to make the tool usable in the MCP Client is to manually modify the server.tool call to ensure inputSchema is properly populated.

const tool = server.tool(
  "get-neme",
  {
    slug: z.string().min(1).describe("The slug of the neme"),
  } as ToolAnnotations,
  async ({ slug }) => {
    return {
      content: [{ type: "text", text: `${slug}` }],
    };
  }
);

Object.assign(tool, {
  inputSchema: z.object({
    slug: z.string().min(1).describe("The slug of the neme"),
  }),
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions