Skip to main content
Glama

example-tool

Process input data strings using a TypeScript-based tool designed for integration into the MCP Server Template, enabling efficient data handling and service-based architecture.

Instructions

An example tool that processes input data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYesInput string to process

Implementation Reference

  • The handler function for 'example-tool' that extracts input, validates with Zod, calls the helper, and returns the processed result or error.
    'example-tool': async (request) => { try { const { input } = request.params.arguments as { input: string } const inputSchema = z.object({ input: z.string().min(1, 'Input must not be empty') }) inputSchema.parse({ input }) const result = await handleExampleProcess(input) return { toolResult: { content: [{ type: 'text', text: result }], }, } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error) throw new Error(`Failed to process input: ${errorMessage}`) } }
  • The complete tool definition for 'example-tool', including name, description, and input schema for validation.
    const EXAMPLE_TOOL: Tool = { name: 'example-tool', description: 'An example tool that processes input data', inputSchema: { type: 'object', properties: { input: { type: 'string', description: 'Input string to process', minLength: 1 } }, required: ['input'] } }
  • src/index.ts:20-23 (registration)
    Merges the example tools and handlers into global collections used for listing tools and dispatching calls in the MCP server.
    // Combine all tools const ALL_TOOLS = [...EXAMPLE_TOOLS] const ALL_HANDLERS = { ...EXAMPLE_HANDLERS }
  • Supporting helper function that performs the core processing logic for the tool input.
    async function handleExampleProcess(input: string): Promise<string> { log('Processing input:', input) return `Processed: ${input}` }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/stevennevins/mcp-server-template'

If you have feedback or need assistance with the MCP directory API, please join our Discord server