UNPKG

@chinchillaenterprises/mcp-ai-assistant

Version:

MCP server for AI assistant with ElevenLabs text-to-speech integration

64 lines 2.55 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); 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 zod_1 = require("zod"); const zod_to_json_schema_1 = require("zod-to-json-schema"); const index_js_2 = require("./tools/account/index.js"); const index_js_3 = require("./tools/tts/index.js"); const list_voices_js_1 = require("./tools/voice/list-voices.js"); const get_voice_js_1 = require("./tools/voice/get-voice.js"); const list_models_js_1 = require("./tools/voice/list-models.js"); const get_usage_js_1 = require("./tools/voice/get-usage.js"); const server = new index_js_1.Server({ name: 'mcp-Ai-assistant', version: '1.0.0', }, { capabilities: { tools: {}, }, }); const allTools = [ ...index_js_2.accountTools, ...index_js_3.ttsTools, list_voices_js_1.listVoicesTool, get_voice_js_1.getVoiceTool, list_models_js_1.listModelsTool, get_usage_js_1.getUsageTool ]; server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({ tools: allTools.map(tool => ({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema ? (0, zod_to_json_schema_1.zodToJsonSchema)(tool.inputSchema) : { type: 'object', properties: {} }, })), })); server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; const tool = allTools.find(t => t.name === name); if (!tool) { throw new types_js_1.McpError(types_js_1.ErrorCode.MethodNotFound, `Unknown tool: ${name}`); } try { const validatedArgs = tool.inputSchema ? tool.inputSchema.parse(args || {}) : (args || {}); return await tool.handler(validatedArgs); } catch (error) { if (error instanceof zod_1.z.ZodError) { throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Invalid arguments: ${error.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(', ')}`); } throw error; } }); async function runServer() { const transport = new stdio_js_1.StdioServerTransport(); await server.connect(transport); console.error('AI Assistant MCP server running on stdio'); } runServer().catch((error) => { console.error('Fatal error in main():', error); process.exit(1); }); //# sourceMappingURL=index.js.map