Skip to main content
Glama

MCPKit

by ribeirogab
greet-class.ts1.21 kB
import { McpServer, type McpTool } from 'simple-mcp'; import { z, ZodObject } from 'zod'; const parameters = { name: z.string().describe('The name is required'), }; /** * GreetTool class implements the McpTool interface * This demonstrates how to create an MCP tool using a class-based approach */ class GreetTool implements McpTool<typeof parameters> { // Tool name public readonly name = 'greet'; // Define parameters with Zod schema public readonly parameters = parameters; /** * Execute method that will be called when the tool is invoked * @param request The validated request parameters */ public async execute({ name }: z.infer<ZodObject<typeof this.parameters>>) { return { content: [ { type: 'text', text: `Hello, ${name}! Nice to meet you.`, }, ], }; } } // Initialize a new MCP server with the name 'greet-server' const server = new McpServer({ name: 'greet-server' }); // Create an instance of the GreetTool class const greetTool = new GreetTool(); // Register the tool with the server server.tool(greetTool); // Start the server using stdio as the transport method server.start({ transportType: 'stdio' });

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/ribeirogab/mcpkit'

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