({ inputs: _inputs, params }, context)
| 68 | }, |
| 69 | }, |
| 70 | async execute({ inputs: _inputs, params }, context) { |
| 71 | const { port } = params; |
| 72 | const { tenantId = 'default' } = context as any; |
| 73 | const volume = new IsolatedContainerVolume(tenantId, context.runId); |
| 74 | |
| 75 | try { |
| 76 | // Create MCP server script |
| 77 | const mcpScript = ` |
| 78 | const http = require('http'); |
| 79 | const url = require('url'); |
| 80 | |
| 81 | // Define tools |
| 82 | const tools = [ |
| 83 | { |
| 84 | name: 'get_weather', |
| 85 | description: 'Get the current weather for a location', |
| 86 | inputSchema: { |
| 87 | type: 'object', |
| 88 | properties: { |
| 89 | location: { |
| 90 | type: 'string', |
| 91 | description: 'City name or location', |
| 92 | }, |
| 93 | }, |
| 94 | required: ['location'], |
| 95 | }, |
| 96 | }, |
| 97 | ]; |
| 98 | |
| 99 | // Create HTTP server |
| 100 | const server = http.createServer((req, res) => { |
| 101 | res.setHeader('Content-Type', 'application/json'); |
| 102 | |
| 103 | // Parse request |
| 104 | const pathname = url.parse(req.url).pathname; |
| 105 | |
| 106 | if (pathname === '/mcp/tools') { |
| 107 | // Tool discovery endpoint |
| 108 | console.error('[MCP-SERVER] Tools discovery request'); |
| 109 | res.writeHead(200); |
| 110 | res.end(JSON.stringify({ tools }, null, 2)); |
| 111 | } else if (pathname === '/mcp/invoke') { |
| 112 | // Tool invocation endpoint |
| 113 | let body = ''; |
| 114 | req.on('data', (chunk) => { body += chunk; }); |
| 115 | req.on('end', () => { |
| 116 | try { |
| 117 | const { tool, input } = JSON.parse(body); |
| 118 | console.error(\`[MCP-SERVER] Tool call: \${tool}\`); |
| 119 | |
| 120 | if (tool === 'get_weather') { |
| 121 | const location = input.location || 'Unknown'; |
| 122 | const result = { |
| 123 | location: location, |
| 124 | temperature: 22, |
| 125 | condition: 'Sunny', |
| 126 | humidity: 65, |
| 127 | wind_speed: 10, |
nothing calls this directly
no test coverage detected