Skip to content

Ability to simply return text from tools/prompts #422

Open
@mikesir87

Description

@mikesir87

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,
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions