sample-tool
Demonstrates how to build custom tools for AI assistants using the MCP Server Template. This sample tool accepts input parameters to show extension creation workflows.
Instructions
A sample tool for demonstration purposes
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | Input parameter for the sample tool |
Implementation Reference
- index.ts:18-31 (handler)The asynchronous handler function for the 'sample-tool' that takes an input string, processes it by prefixing 'Processed: ', and returns it as text content.async ({ input }) => { // Process the input const output = `Processed: ${input}`; // Return the result return { content: [ { type: "text", text: output, }, ], }; }
- index.ts:15-17 (schema)The input schema for the 'sample-tool' defined using Zod, specifying a single string input parameter.{ input: z.string().describe("Input parameter for the sample tool"), },
- index.ts:12-32 (registration)The registration of the 'sample-tool' on the MCP server, including name, description, input schema, and handler function.server.tool( "sample-tool", "A sample tool for demonstration purposes", { input: z.string().describe("Input parameter for the sample tool"), }, async ({ input }) => { // Process the input const output = `Processed: ${input}`; // Return the result return { content: [ { type: "text", text: output, }, ], }; } );