servers/src/everything/tools/echo.ts
olaservo baf99300a2 Add tool annotations to all Everything server tools
Previously only get-annotated-message had ToolAnnotations. Now all 18
tools explicitly declare readOnlyHint, destructiveHint, idempotentHint,
and openWorldHint so the server serves as a complete reference for
developers implementing tool annotations per the MCP spec.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 05:35:51 -07:00

40 lines
1.1 KiB
TypeScript

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
import { z } from "zod";
// Tool input schema
export const EchoSchema = z.object({
message: z.string().describe("Message to echo"),
});
// Tool configuration
const name = "echo";
const config = {
title: "Echo Tool",
description: "Echoes back the input string",
inputSchema: EchoSchema,
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
};
/**
* Registers the 'echo' tool.
*
* The registered tool validates input arguments using the EchoSchema and
* returns a response that echoes the message provided in the arguments.
*
* @param {McpServer} server - The McpServer instance where the tool will be registered.
* @returns {void}
*/
export const registerEchoTool = (server: McpServer) => {
server.registerTool(name, config, async (args): Promise<CallToolResult> => {
const validatedArgs = EchoSchema.parse(args);
return {
content: [{ type: "text", text: `Echo: ${validatedArgs.message}` }],
};
});
};