Skip to content

type structuredContent indirectly causes type error #2471

@Autumnal-Joy

Description

@Autumnal-Joy

Describe the bug
structuredContent causes type error

To Reproduce

interface SomeType {
  data: string;
}

const server = new McpServer({
  name: "MCP",
  version: "1.0.0",
});

server.registerTool(
  "name",
  {
    outputSchema: {
      data: z.string(),
    },
  },
  async () => { // type error
    return {} as {
      content: [];
      structuredContent: SomeType;
      isError?: boolean;
    };
  }
);

If I inline the type of structuredContent within the code, it will not report a type error.

const server = new McpServer({
  name: "MCP Refine",
  version: "1.0.0",
});

server.registerTool(
  "name",
  {
    outputSchema: {
      data: z.string(),
    },
  },
  async () => {
    return {} as {
      content: [];
      structuredContent:  {
        data: string;
      };
      isError?: boolean;
    };
  }
);

Expected behavior
Do not cause the type error

Logs

Additional context
"@modelcontextprotocol/sdk": "1.17.1",
"zod": "3.25.76"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions