Skip to main content
Glama
server-test.ts1.81 kB
import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError, } from '@modelcontextprotocol/sdk/types.js'; export class ArchyServer { private server: Server; constructor() { this.server = new Server( { name: 'archy', version: '0.1.0', }, { capabilities: { tools: {}, }, } ); this.setupToolHandlers(); } private setupToolHandlers(): void { const tools = [ { name: 'test_tool', description: 'A test tool', inputSchema: { type: 'object', properties: { test: { type: 'string', description: 'Test parameter', } }, required: ['test'], }, } ]; this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools })); this.server.setRequestHandler(CallToolRequestSchema, async (request) => { switch (request.params.name) { case 'test_tool': return this.handleTestTool(request.params.arguments); default: throw new McpError( ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}` ); } }); } private async handleTestTool(args: any): Promise<object> { return { content: [ { type: 'text', text: `Test tool called with: ${args.test}`, }, ], }; } async run(): Promise<void> { const transport = new StdioServerTransport(); await this.server.connect(transport); console.error('Test MCP server running on stdio'); } }

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/phxdev1/archy-mcp'

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