Skip to content

@ai-sdk/mcp: support structuredContent / outputSchema for typed tool outputs #11441

Description

@mattrossman

Description

MCP allows specifying outputSchema for tools to provide better type information. When specified, tools must populate structuredContent in their result as well as JSON encode structured data in .content text for backwards compatibility.

Currently, there's no way to leverage this type information with AI SDK's MCP client. I'd expect a way to read .structuredContent just as I'd read .content, but with type information from a defined outputSchema.

Spec:

MCPClient.tools() accepts a schemas option for type checking of tool inputs. Currently this only recognizes inputSchema to type tool inputs, while tool outputs are untyped.

Comparatively, regular tool() definitions accept an outputSchema for typed outputs:

AI SDK Version

  • @ai-sdk/mcp: 1.0.1

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions