Skip to main content
Glama

MCP Server Template

by stevennevins
TestClient.ts1.09 kB
import { Tool } from '@modelcontextprotocol/sdk/types.js' import { EXAMPLE_TOOLS, EXAMPLE_HANDLERS } from '../tools/example.js' export type ToolResult = { toolResult: { content: Array<{ type: string; text: string }> } } export class TestClient { private tools: Tool[] private handlers: Record<string, Function> constructor() { this.tools = EXAMPLE_TOOLS this.handlers = EXAMPLE_HANDLERS } async listTools(): Promise<Tool[]> { return this.tools } async callTool(toolName: string, args: Record<string, unknown>): Promise<ToolResult> { const handler = this.handlers[toolName] if (!handler) { throw new Error(`Tool ${toolName} not found`) } return handler({ params: { arguments: args } }) } async assertToolCall( toolName: string, args: Record<string, unknown>, assertion: (result: ToolResult) => void | Promise<void> ): Promise<void> { const result = await this.callTool(toolName, args) await assertion(result) } }

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