Skip to content

Ability to simply return text from tools/prompts #422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mikesir87 opened this issue Apr 28, 2025 · 0 comments
Open

Ability to simply return text from tools/prompts #422

mikesir87 opened this issue Apr 28, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@mikesir87
Copy link

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,
);
@mikesir87 mikesir87 added the enhancement New feature or request label Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant