UNPKG

3gpp-mcp-charging

Version:

3GPP MCP Server V3.0.0 - Direct access to TSpec-LLM dataset (arxiv.org/abs/2406.01768) and 3GPP specifications via external APIs

112 lines 4.74 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ThreeGPPMCPServer = void 0; const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js"); const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js"); const types_js_1 = require("@modelcontextprotocol/sdk/types.js"); const api_1 = require("./api"); const tools_1 = require("./tools"); class ThreeGPPMCPServer { server; apiManager; // V3 Tool instances searchTool; detailsTool; compareTool; requirementsTool; constructor() { this.server = new index_js_1.Server({ name: '3gpp-mcp-server', version: '3.0.0', description: '3GPP MCP Server - Direct access to TSpec-LLM and 3GPP specifications' }, { capabilities: { tools: {}, resources: {}, prompts: {} } }); const apiConfig = { huggingFaceToken: process.env.HUGGINGFACE_TOKEN, enableCaching: true, cacheTimeout: 3600 }; this.apiManager = new api_1.APIManager(apiConfig); this.initializeComponents(); this.setupHandlers(); } initializeComponents() { // Initialize V3 data access tools this.searchTool = new tools_1.SearchSpecificationsTool(this.apiManager); this.detailsTool = new tools_1.GetSpecificationDetailsTool(this.apiManager); this.compareTool = new tools_1.CompareSpecificationsTool(this.apiManager); this.requirementsTool = new tools_1.FindImplementationRequirementsTool(this.apiManager); } setupHandlers() { this.server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => { return { tools: [ this.searchTool.getDefinition(), this.detailsTool.getDefinition(), this.compareTool.getDefinition(), this.requirementsTool.getDefinition() ] }; }); this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { switch (name) { case 'search_specifications': return await this.searchTool.execute(args); case 'get_specification_details': return await this.detailsTool.execute(args); case 'compare_specifications': return await this.compareTool.execute(args); case 'find_implementation_requirements': return await this.requirementsTool.execute(args); default: throw new types_js_1.McpError(types_js_1.ErrorCode.MethodNotFound, `Unknown tool: ${name}`); } } catch (error) { if (error instanceof types_js_1.McpError) { throw error; } throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Tool execution failed: ${error instanceof Error ? error.message : 'Unknown error'}`); } }); // V3 focuses on tools only - no resources or prompts needed this.server.setRequestHandler(types_js_1.ListResourcesRequestSchema, async () => { return { resources: [] }; }); this.server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async () => { throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidRequest, 'Resources not supported in V3 - use tools for data access'); }); this.server.setRequestHandler(types_js_1.ListPromptsRequestSchema, async () => { return { prompts: [] }; }); this.server.setRequestHandler(types_js_1.GetPromptRequestSchema, async () => { throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidRequest, 'Prompts not supported in V3 - use tools for data access'); }); } async run() { try { // No initialization needed for API clients const transport = new stdio_js_1.StdioServerTransport(); await this.server.connect(transport); } catch (error) { console.error('Failed to start 3GPP MCP Server:', error); process.exit(1); } } } exports.ThreeGPPMCPServer = ThreeGPPMCPServer; // Check if this file is being run directly if (require.main === module) { const server = new ThreeGPPMCPServer(); server.run().catch(() => process.exit(1)); } //# sourceMappingURL=index.js.map