Open
Description
Is your feature request related to a problem? Please describe.
When teaching other folks about MCP, the Python SDK makes it pretty easy to define a tool in which the returned text is the response. However, in the TS SDK, you have to wrap the response in a content object, revealing more details about the protocol and raising questions (what's it mean to have more than one content object, etc.).
It would be great if we could allow a tool callback to simply return text and the invoking function can do the necessary wrapping for the protocol.
Example:
Current
server.tool(
"add-two-numbers",
"Add two numbers",
{
a: z.number().describe("The first number to add"),
b: z.number().describe("The second number to add")
},
({ a, b }) => {
return {
content: [{
type: "text",
text: a + b,
}]
}
}
)
Proposal
server.tool(
"add-two-numbers",
"Add two numbers",
{
a: z.number().describe("The first number to add"),
b: z.number().describe("The second number to add")
},
({ a, b }) => a + b,
);