Skip to main content
Glama
server.ts3.46 kB
import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { CallToolRequestSchema, ListToolsRequestSchema, ErrorCode, McpError, } from '@modelcontextprotocol/sdk/types.js'; import { codeAnalysisTools, handleCodeAnalysisTool } from './tools/code-analysis.js'; import { codeQualityTools, handleCodeQualityTool } from './tools/code-quality.js'; import { dependencyAnalysisTools, handleDependencyAnalysisTool } from './tools/dependency-analysis.js'; import { lintingTools, handleLintingTool } from './tools/linting.js'; import { webScrapingTools, handleWebScrapingTool } from './tools/web-scraping.js'; import { apiDiscoveryTools, handleAPIDiscoveryTool } from './tools/api-discovery.js'; // Combine all tools const allTools = [ ...codeAnalysisTools, ...codeQualityTools, ...dependencyAnalysisTools, ...lintingTools, ...webScrapingTools, ...apiDiscoveryTools, ]; export class DevelopmentToolsMCPServer { private server: Server; constructor() { this.server = new Server( { name: 'mcp-development-tools', version: '1.0.0', }, { capabilities: { tools: {}, }, } ); this.setupHandlers(); } private setupHandlers(): void { // List tools this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: allTools, }; }); // Handle tool calls this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { let result: unknown; // Route to appropriate handler if (codeAnalysisTools.some((t) => t.name === name)) { result = await handleCodeAnalysisTool(name, args || {}); } else if (codeQualityTools.some((t) => t.name === name)) { result = await handleCodeQualityTool(name, args || {}); } else if (dependencyAnalysisTools.some((t) => t.name === name)) { result = await handleDependencyAnalysisTool(name, args || {}); } else if (lintingTools.some((t) => t.name === name)) { result = await handleLintingTool(name, args || {}); } else if (webScrapingTools.some((t) => t.name === name)) { result = await handleWebScrapingTool(name, args || {}); } else if (apiDiscoveryTools.some((t) => t.name === name)) { result = await handleAPIDiscoveryTool(name, args || {}); } else { throw new McpError( ErrorCode.MethodNotFound, `Unknown tool: ${name}` ); } return { content: [ { type: 'text', text: typeof result === 'string' ? result : JSON.stringify(result, null, 2), }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); const errorStack = error instanceof Error ? error.stack : undefined; throw new McpError( ErrorCode.InternalError, `Tool execution failed: ${errorMessage}`, { stack: errorStack, } ); } }); } async run(): Promise<void> { const transport = new StdioServerTransport(); await this.server.connect(transport); console.error('MCP Development Tools 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/code-alchemist01/development-tools-mcp-Server'

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