From 8038e9d60b00389a3f63fc20e1856dfcf4355998 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 7 Dec 2025 21:07:28 +0000 Subject: [PATCH 1/6] Initial plan From 53c21dd6a71dfaf15023f8a91ceeb71dc9018889 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 7 Dec 2025 21:12:34 +0000 Subject: [PATCH 2/6] Initial plan for refactoring duplicate MCP server implementations Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> --- .github/workflows/release.lock.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.lock.yml b/.github/workflows/release.lock.yml index a73e060474..160a26701e 100644 --- a/.github/workflows/release.lock.yml +++ b/.github/workflows/release.lock.yml @@ -6119,19 +6119,19 @@ jobs: - name: Download Go modules run: go mod download - name: Generate SBOM (SPDX format) - uses: anchore/sbom-action@fbfd9c6c189226748411491745178e0c2017392d # v0.20.10 + uses: anchore/sbom-action@fbfd9c6c189226748411491745178e0c2017392d # v0 with: artifact-name: sbom.spdx.json format: spdx-json output-file: sbom.spdx.json - name: Generate SBOM (CycloneDX format) - uses: anchore/sbom-action@fbfd9c6c189226748411491745178e0c2017392d # v0.20.10 + uses: anchore/sbom-action@fbfd9c6c189226748411491745178e0c2017392d # v0 with: artifact-name: sbom.cdx.json format: cyclonedx-json output-file: sbom.cdx.json - name: Upload SBOM artifacts - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: name: sbom-artifacts path: | From d042fb262854b53559db471f6edae8571120d658 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 7 Dec 2025 21:23:00 +0000 Subject: [PATCH 3/6] Refactor: consolidate MCP server implementations into mcp_server_core.cjs - Extended mcp_server_core.cjs with handleRequest() function for HTTP transport - Updated mcp_http_transport.cjs to use mcp_server_core.cjs via MCPServer wrapper - Removed duplicate mcp_server.cjs file and its test - Updated Go embed directives and script registry - All MCP transport tests passing (mcp_http_transport.test.cjs, mcp_server_core.test.cjs) - Single source of truth for JSON-RPC protocol handling Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> --- .github/workflows/ai-triage-campaign.lock.yml | 90 ++++++ .github/workflows/archie.lock.yml | 90 ++++++ .github/workflows/artifacts-summary.lock.yml | 90 ++++++ .github/workflows/audit-workflows.lock.yml | 90 ++++++ .github/workflows/blog-auditor.lock.yml | 90 ++++++ .github/workflows/brave.lock.yml | 90 ++++++ .../breaking-change-checker.lock.yml | 90 ++++++ .github/workflows/changeset.lock.yml | 90 ++++++ .github/workflows/ci-doctor.lock.yml | 90 ++++++ .../cli-consistency-checker.lock.yml | 90 ++++++ .../workflows/cli-version-checker.lock.yml | 90 ++++++ .github/workflows/cloclo.lock.yml | 90 ++++++ .../workflows/close-old-discussions.lock.yml | 90 ++++++ .../commit-changes-analyzer.lock.yml | 90 ++++++ .../workflows/copilot-agent-analysis.lock.yml | 90 ++++++ .../copilot-pr-merged-report.lock.yml | 280 ++++++++++++------ .../copilot-pr-nlp-analysis.lock.yml | 90 ++++++ .../copilot-pr-prompt-analysis.lock.yml | 90 ++++++ .../copilot-session-insights.lock.yml | 90 ++++++ .github/workflows/craft.lock.yml | 90 ++++++ .../daily-assign-issue-to-user.lock.yml | 90 ++++++ .github/workflows/daily-code-metrics.lock.yml | 90 ++++++ .../daily-copilot-token-report.lock.yml | 90 ++++++ .github/workflows/daily-doc-updater.lock.yml | 90 ++++++ .github/workflows/daily-fact.lock.yml | 90 ++++++ .github/workflows/daily-file-diet.lock.yml | 90 ++++++ .../workflows/daily-firewall-report.lock.yml | 90 ++++++ .../workflows/daily-issues-report.lock.yml | 90 ++++++ .../daily-malicious-code-scan.lock.yml | 90 ++++++ .../daily-multi-device-docs-tester.lock.yml | 90 ++++++ .github/workflows/daily-news.lock.yml | 90 ++++++ .../daily-performance-summary.lock.yml | 280 ++++++++++++------ .../workflows/daily-repo-chronicle.lock.yml | 90 ++++++ .../workflows/daily-workflow-updater.lock.yml | 90 ++++++ .github/workflows/deep-report.lock.yml | 90 ++++++ .../workflows/dependabot-go-checker.lock.yml | 90 ++++++ .github/workflows/dev-hawk.lock.yml | 90 ++++++ .github/workflows/dev.lock.yml | 190 ++++++------ .../developer-docs-consolidator.lock.yml | 90 ++++++ .github/workflows/dictation-prompt.lock.yml | 90 ++++++ .github/workflows/docs-noob-tester.lock.yml | 90 ++++++ .../duplicate-code-detector.lock.yml | 90 ++++++ .../example-workflow-analyzer.lock.yml | 90 ++++++ .../github-mcp-structural-analysis.lock.yml | 90 ++++++ .../github-mcp-tools-report.lock.yml | 90 ++++++ .../workflows/glossary-maintainer.lock.yml | 90 ++++++ .github/workflows/go-fan.lock.yml | 90 ++++++ .github/workflows/go-logger.lock.yml | 90 ++++++ .../workflows/go-pattern-detector.lock.yml | 90 ++++++ .github/workflows/grumpy-reviewer.lock.yml | 90 ++++++ .../workflows/instructions-janitor.lock.yml | 90 ++++++ .github/workflows/issue-arborist.lock.yml | 90 ++++++ .github/workflows/issue-classifier.lock.yml | 90 ++++++ .github/workflows/issue-monster.lock.yml | 90 ++++++ .github/workflows/issue-triage-agent.lock.yml | 90 ++++++ .github/workflows/lockfile-stats.lock.yml | 90 ++++++ .github/workflows/mcp-inspector.lock.yml | 90 ++++++ .github/workflows/mergefest.lock.yml | 90 ++++++ .../workflows/notion-issue-summary.lock.yml | 90 ++++++ .github/workflows/org-health-report.lock.yml | 90 ++++++ .github/workflows/pdf-summary.lock.yml | 90 ++++++ .github/workflows/plan.lock.yml | 90 ++++++ .github/workflows/poem-bot.lock.yml | 90 ++++++ .../workflows/pr-nitpick-reviewer.lock.yml | 90 ++++++ .../prompt-clustering-analysis.lock.yml | 90 ++++++ .github/workflows/python-data-charts.lock.yml | 90 ++++++ .github/workflows/q.lock.yml | 90 ++++++ .github/workflows/release.lock.yml | 96 +++++- .github/workflows/repo-tree-map.lock.yml | 90 ++++++ .../repository-quality-improver.lock.yml | 90 ++++++ .github/workflows/research.lock.yml | 90 ++++++ .github/workflows/safe-output-health.lock.yml | 90 ++++++ .../schema-consistency-checker.lock.yml | 90 ++++++ .github/workflows/scout.lock.yml | 90 ++++++ .github/workflows/security-fix-pr.lock.yml | 90 ++++++ .../semantic-function-refactor.lock.yml | 90 ++++++ .github/workflows/smoke-claude.lock.yml | 90 ++++++ .github/workflows/smoke-codex.lock.yml | 90 ++++++ .../smoke-copilot-no-firewall.lock.yml | 90 ++++++ .../smoke-copilot-playwright.lock.yml | 280 ++++++++++++------ .../smoke-copilot-safe-inputs.lock.yml | 280 ++++++++++++------ .github/workflows/smoke-copilot.lock.yml | 90 ++++++ .github/workflows/smoke-detector.lock.yml | 90 ++++++ .github/workflows/smoke-srt.lock.yml | 90 ++++++ .github/workflows/spec-kit-executor.lock.yml | 90 ++++++ .github/workflows/speckit-dispatcher.lock.yml | 90 ++++++ .../workflows/stale-repo-identifier.lock.yml | 90 ++++++ .../workflows/static-analysis-report.lock.yml | 90 ++++++ .github/workflows/super-linter.lock.yml | 90 ++++++ .../workflows/technical-doc-writer.lock.yml | 90 ++++++ .../test-discussion-expires.lock.yml | 90 ++++++ .../workflows/test-python-safe-input.lock.yml | 280 ++++++++++++------ .github/workflows/tidy.lock.yml | 90 ++++++ .github/workflows/typist.lock.yml | 90 ++++++ .github/workflows/unbloat-docs.lock.yml | 90 ++++++ .github/workflows/video-analyzer.lock.yml | 90 ++++++ .../workflows/weekly-issue-summary.lock.yml | 90 ++++++ pkg/cli/mcp_inspect.go | 1 - pkg/workflow/js.go | 6 - pkg/workflow/js/mcp_http_transport.cjs | 71 ++++- pkg/workflow/js/mcp_server.cjs | 191 ------------ pkg/workflow/js/mcp_server.test.cjs | 225 -------------- pkg/workflow/js/mcp_server_core.cjs | 116 +++++++- pkg/workflow/mcp_servers.go | 6 - pkg/workflow/scripts.go | 4 - 105 files changed, 9458 insertions(+), 948 deletions(-) delete mode 100644 pkg/workflow/js/mcp_server.cjs delete mode 100644 pkg/workflow/js/mcp_server.test.cjs diff --git a/.github/workflows/ai-triage-campaign.lock.yml b/.github/workflows/ai-triage-campaign.lock.yml index 5a9b917a0f..32ea2409a3 100644 --- a/.github/workflows/ai-triage-campaign.lock.yml +++ b/.github/workflows/ai-triage-campaign.lock.yml @@ -974,6 +974,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/archie.lock.yml b/.github/workflows/archie.lock.yml index cb684fffa9..eec1303fe6 100644 --- a/.github/workflows/archie.lock.yml +++ b/.github/workflows/archie.lock.yml @@ -2461,6 +2461,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/artifacts-summary.lock.yml b/.github/workflows/artifacts-summary.lock.yml index 7b93a9617e..e3c8b085b0 100644 --- a/.github/workflows/artifacts-summary.lock.yml +++ b/.github/workflows/artifacts-summary.lock.yml @@ -1045,6 +1045,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/audit-workflows.lock.yml b/.github/workflows/audit-workflows.lock.yml index 5b2a9c61b5..f7fc807667 100644 --- a/.github/workflows/audit-workflows.lock.yml +++ b/.github/workflows/audit-workflows.lock.yml @@ -1862,6 +1862,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/blog-auditor.lock.yml b/.github/workflows/blog-auditor.lock.yml index df3dd99e4f..2d0b7abc44 100644 --- a/.github/workflows/blog-auditor.lock.yml +++ b/.github/workflows/blog-auditor.lock.yml @@ -1360,6 +1360,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/brave.lock.yml b/.github/workflows/brave.lock.yml index 9109abe1ec..25fd4c9467 100644 --- a/.github/workflows/brave.lock.yml +++ b/.github/workflows/brave.lock.yml @@ -2346,6 +2346,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/breaking-change-checker.lock.yml b/.github/workflows/breaking-change-checker.lock.yml index 192ae63e43..9f81bfb7a1 100644 --- a/.github/workflows/breaking-change-checker.lock.yml +++ b/.github/workflows/breaking-change-checker.lock.yml @@ -1092,6 +1092,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/changeset.lock.yml b/.github/workflows/changeset.lock.yml index edaf972fed..88b99a88ed 100644 --- a/.github/workflows/changeset.lock.yml +++ b/.github/workflows/changeset.lock.yml @@ -1965,6 +1965,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/ci-doctor.lock.yml b/.github/workflows/ci-doctor.lock.yml index bec6519b9b..f0a99b1f5c 100644 --- a/.github/workflows/ci-doctor.lock.yml +++ b/.github/workflows/ci-doctor.lock.yml @@ -1779,6 +1779,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/cli-consistency-checker.lock.yml b/.github/workflows/cli-consistency-checker.lock.yml index 70bec5537a..222eb33a32 100644 --- a/.github/workflows/cli-consistency-checker.lock.yml +++ b/.github/workflows/cli-consistency-checker.lock.yml @@ -1093,6 +1093,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/cli-version-checker.lock.yml b/.github/workflows/cli-version-checker.lock.yml index b21995706c..c083e432a2 100644 --- a/.github/workflows/cli-version-checker.lock.yml +++ b/.github/workflows/cli-version-checker.lock.yml @@ -1366,6 +1366,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/cloclo.lock.yml b/.github/workflows/cloclo.lock.yml index dcebc5254c..7bca2845fe 100644 --- a/.github/workflows/cloclo.lock.yml +++ b/.github/workflows/cloclo.lock.yml @@ -2766,6 +2766,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/close-old-discussions.lock.yml b/.github/workflows/close-old-discussions.lock.yml index e8dc6a8df5..de9a19630c 100644 --- a/.github/workflows/close-old-discussions.lock.yml +++ b/.github/workflows/close-old-discussions.lock.yml @@ -1260,6 +1260,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/commit-changes-analyzer.lock.yml b/.github/workflows/commit-changes-analyzer.lock.yml index 7457c3bad8..d403a9a1e7 100644 --- a/.github/workflows/commit-changes-analyzer.lock.yml +++ b/.github/workflows/commit-changes-analyzer.lock.yml @@ -1319,6 +1319,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/copilot-agent-analysis.lock.yml b/.github/workflows/copilot-agent-analysis.lock.yml index a9f5559a4b..2a56e525ee 100644 --- a/.github/workflows/copilot-agent-analysis.lock.yml +++ b/.github/workflows/copilot-agent-analysis.lock.yml @@ -1674,6 +1674,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/copilot-pr-merged-report.lock.yml b/.github/workflows/copilot-pr-merged-report.lock.yml index 017c046a3d..396f57071b 100644 --- a/.github/workflows/copilot-pr-merged-report.lock.yml +++ b/.github/workflows/copilot-pr-merged-report.lock.yml @@ -1223,6 +1223,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); @@ -2151,6 +2241,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); @@ -2262,15 +2442,20 @@ jobs: createServer, registerTool, normalizeTool, + handleRequest, handleMessage, processReadBuffer, start, loadToolHandlers, }; EOF_MCP_CORE - cat > /tmp/gh-aw/safe-inputs/mcp_server.cjs << 'EOF_MCP_SERVER' + cat > /tmp/gh-aw/safe-inputs/mcp_http_transport.cjs << 'EOF_MCP_HTTP_TRANSPORT' + const http = require("http"); + const { randomUUID } = require("crypto"); + const { createServer, registerTool, handleRequest } = require("./mcp_server_core.cjs"); class MCPServer { constructor(serverInfo, options = {}) { + this._coreServer = createServer(serverInfo, options); this.serverInfo = serverInfo; this.capabilities = options.capabilities || { tools: {} }; this.tools = new Map(); @@ -2284,100 +2469,25 @@ jobs: inputSchema, handler, }); + registerTool(this._coreServer, { + name, + description, + inputSchema, + handler, + }); } async connect(transport) { this.transport = transport; transport.setServer(this); await transport.start(); } - handleInitialize(params) { - this.initialized = true; - return { - protocolVersion: params.protocolVersion || "2024-11-05", - serverInfo: this.serverInfo, - capabilities: this.capabilities, - }; - } - handleToolsList() { - const tools = Array.from(this.tools.values()).map(tool => ({ - name: tool.name, - description: tool.description, - inputSchema: tool.inputSchema, - })); - return { tools }; - } - async handleToolsCall(params) { - const tool = this.tools.get(params.name); - if (!tool) { - throw { - code: -32602, - message: `Tool '${params.name}' not found`, - }; - } - try { - const result = await tool.handler(params.arguments || {}); - return result; - } catch (error) { - throw { - code: -32603, - message: error instanceof Error ? error.message : String(error), - }; - } - } - handlePing() { - return {}; - } async handleRequest(request) { - const { id, method, params } = request; - try { - if (!("id" in request)) { - return null; - } - let result; - switch (method) { - case "initialize": - result = this.handleInitialize(params || {}); - break; - case "ping": - result = this.handlePing(); - break; - case "tools/list": - result = this.handleToolsList(); - break; - case "tools/call": - result = await this.handleToolsCall(params || {}); - break; - default: - throw { - code: -32601, - message: `Method '${method}' not found`, - }; - } - return { - jsonrpc: "2.0", - id, - result, - }; - } catch (error) { - return { - jsonrpc: "2.0", - id, - error: { - code: error.code || -32603, - message: error.message || "Internal error", - }, - }; + if (request.method === "initialize") { + this.initialized = true; } + return handleRequest(this._coreServer, request); } } - module.exports = { - MCPServer, - }; - EOF_MCP_SERVER - cat > /tmp/gh-aw/safe-inputs/mcp_http_transport.cjs << 'EOF_MCP_HTTP_TRANSPORT' - const http = require("http"); - const { randomUUID } = require("crypto"); - const { MCPServer } = require("./mcp_server.cjs"); class MCPHTTPTransport { constructor(options = {}) { this.sessionIdGenerator = options.sessionIdGenerator; diff --git a/.github/workflows/copilot-pr-nlp-analysis.lock.yml b/.github/workflows/copilot-pr-nlp-analysis.lock.yml index ad248b00c4..0e01e8fc81 100644 --- a/.github/workflows/copilot-pr-nlp-analysis.lock.yml +++ b/.github/workflows/copilot-pr-nlp-analysis.lock.yml @@ -1889,6 +1889,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/copilot-pr-prompt-analysis.lock.yml b/.github/workflows/copilot-pr-prompt-analysis.lock.yml index 08ba4114f9..79ac0a37e4 100644 --- a/.github/workflows/copilot-pr-prompt-analysis.lock.yml +++ b/.github/workflows/copilot-pr-prompt-analysis.lock.yml @@ -1389,6 +1389,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/copilot-session-insights.lock.yml b/.github/workflows/copilot-session-insights.lock.yml index ffee03280a..8da52394aa 100644 --- a/.github/workflows/copilot-session-insights.lock.yml +++ b/.github/workflows/copilot-session-insights.lock.yml @@ -2404,6 +2404,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/craft.lock.yml b/.github/workflows/craft.lock.yml index 2044a11a3b..7459968c01 100644 --- a/.github/workflows/craft.lock.yml +++ b/.github/workflows/craft.lock.yml @@ -2556,6 +2556,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/daily-assign-issue-to-user.lock.yml b/.github/workflows/daily-assign-issue-to-user.lock.yml index cbdcae7d54..6e66fd0edc 100644 --- a/.github/workflows/daily-assign-issue-to-user.lock.yml +++ b/.github/workflows/daily-assign-issue-to-user.lock.yml @@ -1537,6 +1537,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/daily-code-metrics.lock.yml b/.github/workflows/daily-code-metrics.lock.yml index 8504371814..74cef0b01f 100644 --- a/.github/workflows/daily-code-metrics.lock.yml +++ b/.github/workflows/daily-code-metrics.lock.yml @@ -1906,6 +1906,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/daily-copilot-token-report.lock.yml b/.github/workflows/daily-copilot-token-report.lock.yml index 4c5d9b1491..0beeeeaa3e 100644 --- a/.github/workflows/daily-copilot-token-report.lock.yml +++ b/.github/workflows/daily-copilot-token-report.lock.yml @@ -1957,6 +1957,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/daily-doc-updater.lock.yml b/.github/workflows/daily-doc-updater.lock.yml index cc2bd2b97f..74cf3cb4ba 100644 --- a/.github/workflows/daily-doc-updater.lock.yml +++ b/.github/workflows/daily-doc-updater.lock.yml @@ -1218,6 +1218,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/daily-fact.lock.yml b/.github/workflows/daily-fact.lock.yml index de18c4ff4d..c9f10c630e 100644 --- a/.github/workflows/daily-fact.lock.yml +++ b/.github/workflows/daily-fact.lock.yml @@ -1546,6 +1546,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/daily-file-diet.lock.yml b/.github/workflows/daily-file-diet.lock.yml index b9bab5653d..02e5e2e473 100644 --- a/.github/workflows/daily-file-diet.lock.yml +++ b/.github/workflows/daily-file-diet.lock.yml @@ -1243,6 +1243,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/daily-firewall-report.lock.yml b/.github/workflows/daily-firewall-report.lock.yml index 3df31de41b..8c4867d313 100644 --- a/.github/workflows/daily-firewall-report.lock.yml +++ b/.github/workflows/daily-firewall-report.lock.yml @@ -1658,6 +1658,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/daily-issues-report.lock.yml b/.github/workflows/daily-issues-report.lock.yml index 896b6c36ab..918786dd61 100644 --- a/.github/workflows/daily-issues-report.lock.yml +++ b/.github/workflows/daily-issues-report.lock.yml @@ -2051,6 +2051,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/daily-malicious-code-scan.lock.yml b/.github/workflows/daily-malicious-code-scan.lock.yml index 225ba51a43..bce20ae589 100644 --- a/.github/workflows/daily-malicious-code-scan.lock.yml +++ b/.github/workflows/daily-malicious-code-scan.lock.yml @@ -1223,6 +1223,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/daily-multi-device-docs-tester.lock.yml b/.github/workflows/daily-multi-device-docs-tester.lock.yml index d2f678ba2b..0d971916af 100644 --- a/.github/workflows/daily-multi-device-docs-tester.lock.yml +++ b/.github/workflows/daily-multi-device-docs-tester.lock.yml @@ -1175,6 +1175,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/daily-news.lock.yml b/.github/workflows/daily-news.lock.yml index 815a9afb9d..6ced91ff2e 100644 --- a/.github/workflows/daily-news.lock.yml +++ b/.github/workflows/daily-news.lock.yml @@ -1976,6 +1976,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/daily-performance-summary.lock.yml b/.github/workflows/daily-performance-summary.lock.yml index f6b7a8ce71..d59e4d1b9e 100644 --- a/.github/workflows/daily-performance-summary.lock.yml +++ b/.github/workflows/daily-performance-summary.lock.yml @@ -1813,6 +1813,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); @@ -2741,6 +2831,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); @@ -2852,15 +3032,20 @@ jobs: createServer, registerTool, normalizeTool, + handleRequest, handleMessage, processReadBuffer, start, loadToolHandlers, }; EOF_MCP_CORE - cat > /tmp/gh-aw/safe-inputs/mcp_server.cjs << 'EOF_MCP_SERVER' + cat > /tmp/gh-aw/safe-inputs/mcp_http_transport.cjs << 'EOF_MCP_HTTP_TRANSPORT' + const http = require("http"); + const { randomUUID } = require("crypto"); + const { createServer, registerTool, handleRequest } = require("./mcp_server_core.cjs"); class MCPServer { constructor(serverInfo, options = {}) { + this._coreServer = createServer(serverInfo, options); this.serverInfo = serverInfo; this.capabilities = options.capabilities || { tools: {} }; this.tools = new Map(); @@ -2874,100 +3059,25 @@ jobs: inputSchema, handler, }); + registerTool(this._coreServer, { + name, + description, + inputSchema, + handler, + }); } async connect(transport) { this.transport = transport; transport.setServer(this); await transport.start(); } - handleInitialize(params) { - this.initialized = true; - return { - protocolVersion: params.protocolVersion || "2024-11-05", - serverInfo: this.serverInfo, - capabilities: this.capabilities, - }; - } - handleToolsList() { - const tools = Array.from(this.tools.values()).map(tool => ({ - name: tool.name, - description: tool.description, - inputSchema: tool.inputSchema, - })); - return { tools }; - } - async handleToolsCall(params) { - const tool = this.tools.get(params.name); - if (!tool) { - throw { - code: -32602, - message: `Tool '${params.name}' not found`, - }; - } - try { - const result = await tool.handler(params.arguments || {}); - return result; - } catch (error) { - throw { - code: -32603, - message: error instanceof Error ? error.message : String(error), - }; - } - } - handlePing() { - return {}; - } async handleRequest(request) { - const { id, method, params } = request; - try { - if (!("id" in request)) { - return null; - } - let result; - switch (method) { - case "initialize": - result = this.handleInitialize(params || {}); - break; - case "ping": - result = this.handlePing(); - break; - case "tools/list": - result = this.handleToolsList(); - break; - case "tools/call": - result = await this.handleToolsCall(params || {}); - break; - default: - throw { - code: -32601, - message: `Method '${method}' not found`, - }; - } - return { - jsonrpc: "2.0", - id, - result, - }; - } catch (error) { - return { - jsonrpc: "2.0", - id, - error: { - code: error.code || -32603, - message: error.message || "Internal error", - }, - }; + if (request.method === "initialize") { + this.initialized = true; } + return handleRequest(this._coreServer, request); } } - module.exports = { - MCPServer, - }; - EOF_MCP_SERVER - cat > /tmp/gh-aw/safe-inputs/mcp_http_transport.cjs << 'EOF_MCP_HTTP_TRANSPORT' - const http = require("http"); - const { randomUUID } = require("crypto"); - const { MCPServer } = require("./mcp_server.cjs"); class MCPHTTPTransport { constructor(options = {}) { this.sessionIdGenerator = options.sessionIdGenerator; diff --git a/.github/workflows/daily-repo-chronicle.lock.yml b/.github/workflows/daily-repo-chronicle.lock.yml index 22b33130ed..069ba5c4bb 100644 --- a/.github/workflows/daily-repo-chronicle.lock.yml +++ b/.github/workflows/daily-repo-chronicle.lock.yml @@ -1661,6 +1661,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/daily-workflow-updater.lock.yml b/.github/workflows/daily-workflow-updater.lock.yml index ca62972b5e..a2d826fa72 100644 --- a/.github/workflows/daily-workflow-updater.lock.yml +++ b/.github/workflows/daily-workflow-updater.lock.yml @@ -1084,6 +1084,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/deep-report.lock.yml b/.github/workflows/deep-report.lock.yml index 2fc56da2b4..3914ff29e4 100644 --- a/.github/workflows/deep-report.lock.yml +++ b/.github/workflows/deep-report.lock.yml @@ -1533,6 +1533,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/dependabot-go-checker.lock.yml b/.github/workflows/dependabot-go-checker.lock.yml index 45b396a76d..18011b3566 100644 --- a/.github/workflows/dependabot-go-checker.lock.yml +++ b/.github/workflows/dependabot-go-checker.lock.yml @@ -1396,6 +1396,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/dev-hawk.lock.yml b/.github/workflows/dev-hawk.lock.yml index a82b70b3fb..869218239a 100644 --- a/.github/workflows/dev-hawk.lock.yml +++ b/.github/workflows/dev-hawk.lock.yml @@ -1610,6 +1610,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/dev.lock.yml b/.github/workflows/dev.lock.yml index 32a106fa1e..e8d7e2f524 100644 --- a/.github/workflows/dev.lock.yml +++ b/.github/workflows/dev.lock.yml @@ -736,6 +736,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); @@ -847,15 +937,20 @@ jobs: createServer, registerTool, normalizeTool, + handleRequest, handleMessage, processReadBuffer, start, loadToolHandlers, }; EOF_MCP_CORE - cat > /tmp/gh-aw/safe-inputs/mcp_server.cjs << 'EOF_MCP_SERVER' + cat > /tmp/gh-aw/safe-inputs/mcp_http_transport.cjs << 'EOF_MCP_HTTP_TRANSPORT' + const http = require("http"); + const { randomUUID } = require("crypto"); + const { createServer, registerTool, handleRequest } = require("./mcp_server_core.cjs"); class MCPServer { constructor(serverInfo, options = {}) { + this._coreServer = createServer(serverInfo, options); this.serverInfo = serverInfo; this.capabilities = options.capabilities || { tools: {} }; this.tools = new Map(); @@ -869,100 +964,25 @@ jobs: inputSchema, handler, }); + registerTool(this._coreServer, { + name, + description, + inputSchema, + handler, + }); } async connect(transport) { this.transport = transport; transport.setServer(this); await transport.start(); } - handleInitialize(params) { - this.initialized = true; - return { - protocolVersion: params.protocolVersion || "2024-11-05", - serverInfo: this.serverInfo, - capabilities: this.capabilities, - }; - } - handleToolsList() { - const tools = Array.from(this.tools.values()).map(tool => ({ - name: tool.name, - description: tool.description, - inputSchema: tool.inputSchema, - })); - return { tools }; - } - async handleToolsCall(params) { - const tool = this.tools.get(params.name); - if (!tool) { - throw { - code: -32602, - message: `Tool '${params.name}' not found`, - }; - } - try { - const result = await tool.handler(params.arguments || {}); - return result; - } catch (error) { - throw { - code: -32603, - message: error instanceof Error ? error.message : String(error), - }; - } - } - handlePing() { - return {}; - } async handleRequest(request) { - const { id, method, params } = request; - try { - if (!("id" in request)) { - return null; - } - let result; - switch (method) { - case "initialize": - result = this.handleInitialize(params || {}); - break; - case "ping": - result = this.handlePing(); - break; - case "tools/list": - result = this.handleToolsList(); - break; - case "tools/call": - result = await this.handleToolsCall(params || {}); - break; - default: - throw { - code: -32601, - message: `Method '${method}' not found`, - }; - } - return { - jsonrpc: "2.0", - id, - result, - }; - } catch (error) { - return { - jsonrpc: "2.0", - id, - error: { - code: error.code || -32603, - message: error.message || "Internal error", - }, - }; + if (request.method === "initialize") { + this.initialized = true; } + return handleRequest(this._coreServer, request); } } - module.exports = { - MCPServer, - }; - EOF_MCP_SERVER - cat > /tmp/gh-aw/safe-inputs/mcp_http_transport.cjs << 'EOF_MCP_HTTP_TRANSPORT' - const http = require("http"); - const { randomUUID } = require("crypto"); - const { MCPServer } = require("./mcp_server.cjs"); class MCPHTTPTransport { constructor(options = {}) { this.sessionIdGenerator = options.sessionIdGenerator; diff --git a/.github/workflows/developer-docs-consolidator.lock.yml b/.github/workflows/developer-docs-consolidator.lock.yml index 612ebee3e4..d76ca5924b 100644 --- a/.github/workflows/developer-docs-consolidator.lock.yml +++ b/.github/workflows/developer-docs-consolidator.lock.yml @@ -1794,6 +1794,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/dictation-prompt.lock.yml b/.github/workflows/dictation-prompt.lock.yml index 6262a4d13f..64a46425f3 100644 --- a/.github/workflows/dictation-prompt.lock.yml +++ b/.github/workflows/dictation-prompt.lock.yml @@ -1070,6 +1070,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/docs-noob-tester.lock.yml b/.github/workflows/docs-noob-tester.lock.yml index e9d777da9c..76ed9cf778 100644 --- a/.github/workflows/docs-noob-tester.lock.yml +++ b/.github/workflows/docs-noob-tester.lock.yml @@ -1100,6 +1100,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/duplicate-code-detector.lock.yml b/.github/workflows/duplicate-code-detector.lock.yml index 7a77a989e6..0879c8ef8b 100644 --- a/.github/workflows/duplicate-code-detector.lock.yml +++ b/.github/workflows/duplicate-code-detector.lock.yml @@ -1148,6 +1148,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/example-workflow-analyzer.lock.yml b/.github/workflows/example-workflow-analyzer.lock.yml index 78ec3db104..26c7b0e310 100644 --- a/.github/workflows/example-workflow-analyzer.lock.yml +++ b/.github/workflows/example-workflow-analyzer.lock.yml @@ -1117,6 +1117,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/github-mcp-structural-analysis.lock.yml b/.github/workflows/github-mcp-structural-analysis.lock.yml index 0d7038df08..f7445078e9 100644 --- a/.github/workflows/github-mcp-structural-analysis.lock.yml +++ b/.github/workflows/github-mcp-structural-analysis.lock.yml @@ -1761,6 +1761,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/github-mcp-tools-report.lock.yml b/.github/workflows/github-mcp-tools-report.lock.yml index 5d7f50d5fb..49984304eb 100644 --- a/.github/workflows/github-mcp-tools-report.lock.yml +++ b/.github/workflows/github-mcp-tools-report.lock.yml @@ -1645,6 +1645,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/glossary-maintainer.lock.yml b/.github/workflows/glossary-maintainer.lock.yml index e831baa183..654b3d0762 100644 --- a/.github/workflows/glossary-maintainer.lock.yml +++ b/.github/workflows/glossary-maintainer.lock.yml @@ -1584,6 +1584,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/go-fan.lock.yml b/.github/workflows/go-fan.lock.yml index 54741caf6d..f058acc2b5 100644 --- a/.github/workflows/go-fan.lock.yml +++ b/.github/workflows/go-fan.lock.yml @@ -1420,6 +1420,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/go-logger.lock.yml b/.github/workflows/go-logger.lock.yml index e5a9963882..03565b0742 100644 --- a/.github/workflows/go-logger.lock.yml +++ b/.github/workflows/go-logger.lock.yml @@ -1346,6 +1346,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/go-pattern-detector.lock.yml b/.github/workflows/go-pattern-detector.lock.yml index 5176437b4a..be20e2bea0 100644 --- a/.github/workflows/go-pattern-detector.lock.yml +++ b/.github/workflows/go-pattern-detector.lock.yml @@ -1205,6 +1205,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/grumpy-reviewer.lock.yml b/.github/workflows/grumpy-reviewer.lock.yml index 811f53d643..6fa871fca9 100644 --- a/.github/workflows/grumpy-reviewer.lock.yml +++ b/.github/workflows/grumpy-reviewer.lock.yml @@ -2478,6 +2478,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/instructions-janitor.lock.yml b/.github/workflows/instructions-janitor.lock.yml index 4e997b7cb0..ef76a15d22 100644 --- a/.github/workflows/instructions-janitor.lock.yml +++ b/.github/workflows/instructions-janitor.lock.yml @@ -1215,6 +1215,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/issue-arborist.lock.yml b/.github/workflows/issue-arborist.lock.yml index 7f97004ee0..2187c028e3 100644 --- a/.github/workflows/issue-arborist.lock.yml +++ b/.github/workflows/issue-arborist.lock.yml @@ -1194,6 +1194,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/issue-classifier.lock.yml b/.github/workflows/issue-classifier.lock.yml index fcc411f31c..cf88d420dc 100644 --- a/.github/workflows/issue-classifier.lock.yml +++ b/.github/workflows/issue-classifier.lock.yml @@ -2203,6 +2203,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/issue-monster.lock.yml b/.github/workflows/issue-monster.lock.yml index 714d85261c..816a71f204 100644 --- a/.github/workflows/issue-monster.lock.yml +++ b/.github/workflows/issue-monster.lock.yml @@ -1754,6 +1754,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/issue-triage-agent.lock.yml b/.github/workflows/issue-triage-agent.lock.yml index b239371f96..98b9bf7236 100644 --- a/.github/workflows/issue-triage-agent.lock.yml +++ b/.github/workflows/issue-triage-agent.lock.yml @@ -1391,6 +1391,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/lockfile-stats.lock.yml b/.github/workflows/lockfile-stats.lock.yml index 2bac64b37e..c8debad6cf 100644 --- a/.github/workflows/lockfile-stats.lock.yml +++ b/.github/workflows/lockfile-stats.lock.yml @@ -1440,6 +1440,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/mcp-inspector.lock.yml b/.github/workflows/mcp-inspector.lock.yml index 62402e8753..b680ff2140 100644 --- a/.github/workflows/mcp-inspector.lock.yml +++ b/.github/workflows/mcp-inspector.lock.yml @@ -1280,6 +1280,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/mergefest.lock.yml b/.github/workflows/mergefest.lock.yml index 8251f56419..b3c100403d 100644 --- a/.github/workflows/mergefest.lock.yml +++ b/.github/workflows/mergefest.lock.yml @@ -1623,6 +1623,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/notion-issue-summary.lock.yml b/.github/workflows/notion-issue-summary.lock.yml index 5be256c192..f6d0e83b19 100644 --- a/.github/workflows/notion-issue-summary.lock.yml +++ b/.github/workflows/notion-issue-summary.lock.yml @@ -859,6 +859,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/org-health-report.lock.yml b/.github/workflows/org-health-report.lock.yml index 9a78fd7151..0ace008b06 100644 --- a/.github/workflows/org-health-report.lock.yml +++ b/.github/workflows/org-health-report.lock.yml @@ -1869,6 +1869,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/pdf-summary.lock.yml b/.github/workflows/pdf-summary.lock.yml index 1680e79680..d8354d479d 100644 --- a/.github/workflows/pdf-summary.lock.yml +++ b/.github/workflows/pdf-summary.lock.yml @@ -2463,6 +2463,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/plan.lock.yml b/.github/workflows/plan.lock.yml index d9ce6b05a0..b9e7ba724f 100644 --- a/.github/workflows/plan.lock.yml +++ b/.github/workflows/plan.lock.yml @@ -1865,6 +1865,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/poem-bot.lock.yml b/.github/workflows/poem-bot.lock.yml index a3247dc4f6..586452f5a2 100644 --- a/.github/workflows/poem-bot.lock.yml +++ b/.github/workflows/poem-bot.lock.yml @@ -3593,6 +3593,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/pr-nitpick-reviewer.lock.yml b/.github/workflows/pr-nitpick-reviewer.lock.yml index 53e1b06b65..b1ffde16b9 100644 --- a/.github/workflows/pr-nitpick-reviewer.lock.yml +++ b/.github/workflows/pr-nitpick-reviewer.lock.yml @@ -2514,6 +2514,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/prompt-clustering-analysis.lock.yml b/.github/workflows/prompt-clustering-analysis.lock.yml index 1446f514d4..eb88c0550f 100644 --- a/.github/workflows/prompt-clustering-analysis.lock.yml +++ b/.github/workflows/prompt-clustering-analysis.lock.yml @@ -2126,6 +2126,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/python-data-charts.lock.yml b/.github/workflows/python-data-charts.lock.yml index fecf9a968f..76097c892c 100644 --- a/.github/workflows/python-data-charts.lock.yml +++ b/.github/workflows/python-data-charts.lock.yml @@ -1962,6 +1962,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/q.lock.yml b/.github/workflows/q.lock.yml index 3d4a421b0c..8444f28d09 100644 --- a/.github/workflows/q.lock.yml +++ b/.github/workflows/q.lock.yml @@ -2781,6 +2781,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/release.lock.yml b/.github/workflows/release.lock.yml index 160a26701e..f0b6c3cd00 100644 --- a/.github/workflows/release.lock.yml +++ b/.github/workflows/release.lock.yml @@ -1212,6 +1212,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); @@ -6119,19 +6209,19 @@ jobs: - name: Download Go modules run: go mod download - name: Generate SBOM (SPDX format) - uses: anchore/sbom-action@fbfd9c6c189226748411491745178e0c2017392d # v0 + uses: anchore/sbom-action@fbfd9c6c189226748411491745178e0c2017392d # v0.20.10 with: artifact-name: sbom.spdx.json format: spdx-json output-file: sbom.spdx.json - name: Generate SBOM (CycloneDX format) - uses: anchore/sbom-action@fbfd9c6c189226748411491745178e0c2017392d # v0 + uses: anchore/sbom-action@fbfd9c6c189226748411491745178e0c2017392d # v0.20.10 with: artifact-name: sbom.cdx.json format: cyclonedx-json output-file: sbom.cdx.json - name: Upload SBOM artifacts - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5 with: name: sbom-artifacts path: | diff --git a/.github/workflows/repo-tree-map.lock.yml b/.github/workflows/repo-tree-map.lock.yml index c98a78e24c..8f26a262c4 100644 --- a/.github/workflows/repo-tree-map.lock.yml +++ b/.github/workflows/repo-tree-map.lock.yml @@ -1098,6 +1098,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/repository-quality-improver.lock.yml b/.github/workflows/repository-quality-improver.lock.yml index 1fadf001b9..5cbbe9d974 100644 --- a/.github/workflows/repository-quality-improver.lock.yml +++ b/.github/workflows/repository-quality-improver.lock.yml @@ -1559,6 +1559,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/research.lock.yml b/.github/workflows/research.lock.yml index 7c52d468a4..75e35b55e2 100644 --- a/.github/workflows/research.lock.yml +++ b/.github/workflows/research.lock.yml @@ -1020,6 +1020,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/safe-output-health.lock.yml b/.github/workflows/safe-output-health.lock.yml index 0a52ce9858..a4bc56a9c6 100644 --- a/.github/workflows/safe-output-health.lock.yml +++ b/.github/workflows/safe-output-health.lock.yml @@ -1565,6 +1565,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/schema-consistency-checker.lock.yml b/.github/workflows/schema-consistency-checker.lock.yml index a96b93316a..5f5f8ff2aa 100644 --- a/.github/workflows/schema-consistency-checker.lock.yml +++ b/.github/workflows/schema-consistency-checker.lock.yml @@ -1450,6 +1450,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/scout.lock.yml b/.github/workflows/scout.lock.yml index f684ee36ca..6c93d3b352 100644 --- a/.github/workflows/scout.lock.yml +++ b/.github/workflows/scout.lock.yml @@ -2767,6 +2767,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/security-fix-pr.lock.yml b/.github/workflows/security-fix-pr.lock.yml index 9e82e1ffed..2625a45edd 100644 --- a/.github/workflows/security-fix-pr.lock.yml +++ b/.github/workflows/security-fix-pr.lock.yml @@ -1192,6 +1192,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/semantic-function-refactor.lock.yml b/.github/workflows/semantic-function-refactor.lock.yml index 5c554c8a0b..a18145fbe9 100644 --- a/.github/workflows/semantic-function-refactor.lock.yml +++ b/.github/workflows/semantic-function-refactor.lock.yml @@ -1594,6 +1594,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/smoke-claude.lock.yml b/.github/workflows/smoke-claude.lock.yml index 4aa66de93e..309db46b28 100644 --- a/.github/workflows/smoke-claude.lock.yml +++ b/.github/workflows/smoke-claude.lock.yml @@ -2878,6 +2878,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/smoke-codex.lock.yml b/.github/workflows/smoke-codex.lock.yml index 0a099abfa1..fec5e11c13 100644 --- a/.github/workflows/smoke-codex.lock.yml +++ b/.github/workflows/smoke-codex.lock.yml @@ -2648,6 +2648,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/smoke-copilot-no-firewall.lock.yml b/.github/workflows/smoke-copilot-no-firewall.lock.yml index 8bf1c549d8..fae72ff036 100644 --- a/.github/workflows/smoke-copilot-no-firewall.lock.yml +++ b/.github/workflows/smoke-copilot-no-firewall.lock.yml @@ -2721,6 +2721,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/smoke-copilot-playwright.lock.yml b/.github/workflows/smoke-copilot-playwright.lock.yml index f26a3d1841..56433881b0 100644 --- a/.github/workflows/smoke-copilot-playwright.lock.yml +++ b/.github/workflows/smoke-copilot-playwright.lock.yml @@ -2726,6 +2726,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); @@ -3654,6 +3744,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); @@ -3765,15 +3945,20 @@ jobs: createServer, registerTool, normalizeTool, + handleRequest, handleMessage, processReadBuffer, start, loadToolHandlers, }; EOF_MCP_CORE - cat > /tmp/gh-aw/safe-inputs/mcp_server.cjs << 'EOF_MCP_SERVER' + cat > /tmp/gh-aw/safe-inputs/mcp_http_transport.cjs << 'EOF_MCP_HTTP_TRANSPORT' + const http = require("http"); + const { randomUUID } = require("crypto"); + const { createServer, registerTool, handleRequest } = require("./mcp_server_core.cjs"); class MCPServer { constructor(serverInfo, options = {}) { + this._coreServer = createServer(serverInfo, options); this.serverInfo = serverInfo; this.capabilities = options.capabilities || { tools: {} }; this.tools = new Map(); @@ -3787,100 +3972,25 @@ jobs: inputSchema, handler, }); + registerTool(this._coreServer, { + name, + description, + inputSchema, + handler, + }); } async connect(transport) { this.transport = transport; transport.setServer(this); await transport.start(); } - handleInitialize(params) { - this.initialized = true; - return { - protocolVersion: params.protocolVersion || "2024-11-05", - serverInfo: this.serverInfo, - capabilities: this.capabilities, - }; - } - handleToolsList() { - const tools = Array.from(this.tools.values()).map(tool => ({ - name: tool.name, - description: tool.description, - inputSchema: tool.inputSchema, - })); - return { tools }; - } - async handleToolsCall(params) { - const tool = this.tools.get(params.name); - if (!tool) { - throw { - code: -32602, - message: `Tool '${params.name}' not found`, - }; - } - try { - const result = await tool.handler(params.arguments || {}); - return result; - } catch (error) { - throw { - code: -32603, - message: error instanceof Error ? error.message : String(error), - }; - } - } - handlePing() { - return {}; - } async handleRequest(request) { - const { id, method, params } = request; - try { - if (!("id" in request)) { - return null; - } - let result; - switch (method) { - case "initialize": - result = this.handleInitialize(params || {}); - break; - case "ping": - result = this.handlePing(); - break; - case "tools/list": - result = this.handleToolsList(); - break; - case "tools/call": - result = await this.handleToolsCall(params || {}); - break; - default: - throw { - code: -32601, - message: `Method '${method}' not found`, - }; - } - return { - jsonrpc: "2.0", - id, - result, - }; - } catch (error) { - return { - jsonrpc: "2.0", - id, - error: { - code: error.code || -32603, - message: error.message || "Internal error", - }, - }; + if (request.method === "initialize") { + this.initialized = true; } + return handleRequest(this._coreServer, request); } } - module.exports = { - MCPServer, - }; - EOF_MCP_SERVER - cat > /tmp/gh-aw/safe-inputs/mcp_http_transport.cjs << 'EOF_MCP_HTTP_TRANSPORT' - const http = require("http"); - const { randomUUID } = require("crypto"); - const { MCPServer } = require("./mcp_server.cjs"); class MCPHTTPTransport { constructor(options = {}) { this.sessionIdGenerator = options.sessionIdGenerator; diff --git a/.github/workflows/smoke-copilot-safe-inputs.lock.yml b/.github/workflows/smoke-copilot-safe-inputs.lock.yml index dec1c7ae63..338dd4674f 100644 --- a/.github/workflows/smoke-copilot-safe-inputs.lock.yml +++ b/.github/workflows/smoke-copilot-safe-inputs.lock.yml @@ -2626,6 +2626,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); @@ -3554,6 +3644,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); @@ -3665,15 +3845,20 @@ jobs: createServer, registerTool, normalizeTool, + handleRequest, handleMessage, processReadBuffer, start, loadToolHandlers, }; EOF_MCP_CORE - cat > /tmp/gh-aw/safe-inputs/mcp_server.cjs << 'EOF_MCP_SERVER' + cat > /tmp/gh-aw/safe-inputs/mcp_http_transport.cjs << 'EOF_MCP_HTTP_TRANSPORT' + const http = require("http"); + const { randomUUID } = require("crypto"); + const { createServer, registerTool, handleRequest } = require("./mcp_server_core.cjs"); class MCPServer { constructor(serverInfo, options = {}) { + this._coreServer = createServer(serverInfo, options); this.serverInfo = serverInfo; this.capabilities = options.capabilities || { tools: {} }; this.tools = new Map(); @@ -3687,100 +3872,25 @@ jobs: inputSchema, handler, }); + registerTool(this._coreServer, { + name, + description, + inputSchema, + handler, + }); } async connect(transport) { this.transport = transport; transport.setServer(this); await transport.start(); } - handleInitialize(params) { - this.initialized = true; - return { - protocolVersion: params.protocolVersion || "2024-11-05", - serverInfo: this.serverInfo, - capabilities: this.capabilities, - }; - } - handleToolsList() { - const tools = Array.from(this.tools.values()).map(tool => ({ - name: tool.name, - description: tool.description, - inputSchema: tool.inputSchema, - })); - return { tools }; - } - async handleToolsCall(params) { - const tool = this.tools.get(params.name); - if (!tool) { - throw { - code: -32602, - message: `Tool '${params.name}' not found`, - }; - } - try { - const result = await tool.handler(params.arguments || {}); - return result; - } catch (error) { - throw { - code: -32603, - message: error instanceof Error ? error.message : String(error), - }; - } - } - handlePing() { - return {}; - } async handleRequest(request) { - const { id, method, params } = request; - try { - if (!("id" in request)) { - return null; - } - let result; - switch (method) { - case "initialize": - result = this.handleInitialize(params || {}); - break; - case "ping": - result = this.handlePing(); - break; - case "tools/list": - result = this.handleToolsList(); - break; - case "tools/call": - result = await this.handleToolsCall(params || {}); - break; - default: - throw { - code: -32601, - message: `Method '${method}' not found`, - }; - } - return { - jsonrpc: "2.0", - id, - result, - }; - } catch (error) { - return { - jsonrpc: "2.0", - id, - error: { - code: error.code || -32603, - message: error.message || "Internal error", - }, - }; + if (request.method === "initialize") { + this.initialized = true; } + return handleRequest(this._coreServer, request); } } - module.exports = { - MCPServer, - }; - EOF_MCP_SERVER - cat > /tmp/gh-aw/safe-inputs/mcp_http_transport.cjs << 'EOF_MCP_HTTP_TRANSPORT' - const http = require("http"); - const { randomUUID } = require("crypto"); - const { MCPServer } = require("./mcp_server.cjs"); class MCPHTTPTransport { constructor(options = {}) { this.sessionIdGenerator = options.sessionIdGenerator; diff --git a/.github/workflows/smoke-copilot.lock.yml b/.github/workflows/smoke-copilot.lock.yml index 41557ae08c..7edd54c011 100644 --- a/.github/workflows/smoke-copilot.lock.yml +++ b/.github/workflows/smoke-copilot.lock.yml @@ -2635,6 +2635,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/smoke-detector.lock.yml b/.github/workflows/smoke-detector.lock.yml index 197f0a8ce1..ceaaf59a24 100644 --- a/.github/workflows/smoke-detector.lock.yml +++ b/.github/workflows/smoke-detector.lock.yml @@ -2487,6 +2487,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/smoke-srt.lock.yml b/.github/workflows/smoke-srt.lock.yml index 69953d6304..68cc65a608 100644 --- a/.github/workflows/smoke-srt.lock.yml +++ b/.github/workflows/smoke-srt.lock.yml @@ -890,6 +890,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/spec-kit-executor.lock.yml b/.github/workflows/spec-kit-executor.lock.yml index be91499c83..2adbcc5214 100644 --- a/.github/workflows/spec-kit-executor.lock.yml +++ b/.github/workflows/spec-kit-executor.lock.yml @@ -1212,6 +1212,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/speckit-dispatcher.lock.yml b/.github/workflows/speckit-dispatcher.lock.yml index 70b1651a56..3c28ab8344 100644 --- a/.github/workflows/speckit-dispatcher.lock.yml +++ b/.github/workflows/speckit-dispatcher.lock.yml @@ -2626,6 +2626,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/stale-repo-identifier.lock.yml b/.github/workflows/stale-repo-identifier.lock.yml index 10785842a7..62fc176073 100644 --- a/.github/workflows/stale-repo-identifier.lock.yml +++ b/.github/workflows/stale-repo-identifier.lock.yml @@ -1959,6 +1959,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/static-analysis-report.lock.yml b/.github/workflows/static-analysis-report.lock.yml index 46b013bd82..e90ea11700 100644 --- a/.github/workflows/static-analysis-report.lock.yml +++ b/.github/workflows/static-analysis-report.lock.yml @@ -1474,6 +1474,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/super-linter.lock.yml b/.github/workflows/super-linter.lock.yml index 92c6604ae4..55661d972e 100644 --- a/.github/workflows/super-linter.lock.yml +++ b/.github/workflows/super-linter.lock.yml @@ -1214,6 +1214,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/technical-doc-writer.lock.yml b/.github/workflows/technical-doc-writer.lock.yml index 0cf7d7c535..8992ffe21e 100644 --- a/.github/workflows/technical-doc-writer.lock.yml +++ b/.github/workflows/technical-doc-writer.lock.yml @@ -2072,6 +2072,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/test-discussion-expires.lock.yml b/.github/workflows/test-discussion-expires.lock.yml index e782b964d0..ea13025d8d 100644 --- a/.github/workflows/test-discussion-expires.lock.yml +++ b/.github/workflows/test-discussion-expires.lock.yml @@ -891,6 +891,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/test-python-safe-input.lock.yml b/.github/workflows/test-python-safe-input.lock.yml index dd13a92b0a..0d918d384d 100644 --- a/.github/workflows/test-python-safe-input.lock.yml +++ b/.github/workflows/test-python-safe-input.lock.yml @@ -995,6 +995,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); @@ -1923,6 +2013,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); @@ -2034,15 +2214,20 @@ jobs: createServer, registerTool, normalizeTool, + handleRequest, handleMessage, processReadBuffer, start, loadToolHandlers, }; EOF_MCP_CORE - cat > /tmp/gh-aw/safe-inputs/mcp_server.cjs << 'EOF_MCP_SERVER' + cat > /tmp/gh-aw/safe-inputs/mcp_http_transport.cjs << 'EOF_MCP_HTTP_TRANSPORT' + const http = require("http"); + const { randomUUID } = require("crypto"); + const { createServer, registerTool, handleRequest } = require("./mcp_server_core.cjs"); class MCPServer { constructor(serverInfo, options = {}) { + this._coreServer = createServer(serverInfo, options); this.serverInfo = serverInfo; this.capabilities = options.capabilities || { tools: {} }; this.tools = new Map(); @@ -2056,100 +2241,25 @@ jobs: inputSchema, handler, }); + registerTool(this._coreServer, { + name, + description, + inputSchema, + handler, + }); } async connect(transport) { this.transport = transport; transport.setServer(this); await transport.start(); } - handleInitialize(params) { - this.initialized = true; - return { - protocolVersion: params.protocolVersion || "2024-11-05", - serverInfo: this.serverInfo, - capabilities: this.capabilities, - }; - } - handleToolsList() { - const tools = Array.from(this.tools.values()).map(tool => ({ - name: tool.name, - description: tool.description, - inputSchema: tool.inputSchema, - })); - return { tools }; - } - async handleToolsCall(params) { - const tool = this.tools.get(params.name); - if (!tool) { - throw { - code: -32602, - message: `Tool '${params.name}' not found`, - }; - } - try { - const result = await tool.handler(params.arguments || {}); - return result; - } catch (error) { - throw { - code: -32603, - message: error instanceof Error ? error.message : String(error), - }; - } - } - handlePing() { - return {}; - } async handleRequest(request) { - const { id, method, params } = request; - try { - if (!("id" in request)) { - return null; - } - let result; - switch (method) { - case "initialize": - result = this.handleInitialize(params || {}); - break; - case "ping": - result = this.handlePing(); - break; - case "tools/list": - result = this.handleToolsList(); - break; - case "tools/call": - result = await this.handleToolsCall(params || {}); - break; - default: - throw { - code: -32601, - message: `Method '${method}' not found`, - }; - } - return { - jsonrpc: "2.0", - id, - result, - }; - } catch (error) { - return { - jsonrpc: "2.0", - id, - error: { - code: error.code || -32603, - message: error.message || "Internal error", - }, - }; + if (request.method === "initialize") { + this.initialized = true; } + return handleRequest(this._coreServer, request); } } - module.exports = { - MCPServer, - }; - EOF_MCP_SERVER - cat > /tmp/gh-aw/safe-inputs/mcp_http_transport.cjs << 'EOF_MCP_HTTP_TRANSPORT' - const http = require("http"); - const { randomUUID } = require("crypto"); - const { MCPServer } = require("./mcp_server.cjs"); class MCPHTTPTransport { constructor(options = {}) { this.sessionIdGenerator = options.sessionIdGenerator; diff --git a/.github/workflows/tidy.lock.yml b/.github/workflows/tidy.lock.yml index 0b08a6fa5e..e6c750b967 100644 --- a/.github/workflows/tidy.lock.yml +++ b/.github/workflows/tidy.lock.yml @@ -1502,6 +1502,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/typist.lock.yml b/.github/workflows/typist.lock.yml index 0876f1e719..83f0b8a8fe 100644 --- a/.github/workflows/typist.lock.yml +++ b/.github/workflows/typist.lock.yml @@ -1579,6 +1579,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/unbloat-docs.lock.yml b/.github/workflows/unbloat-docs.lock.yml index 1590b82168..df2269f024 100644 --- a/.github/workflows/unbloat-docs.lock.yml +++ b/.github/workflows/unbloat-docs.lock.yml @@ -2529,6 +2529,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/video-analyzer.lock.yml b/.github/workflows/video-analyzer.lock.yml index 0db0bc467c..6ca6918214 100644 --- a/.github/workflows/video-analyzer.lock.yml +++ b/.github/workflows/video-analyzer.lock.yml @@ -1206,6 +1206,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/weekly-issue-summary.lock.yml b/.github/workflows/weekly-issue-summary.lock.yml index 540f1eeb0a..62d8c9e4d7 100644 --- a/.github/workflows/weekly-issue-summary.lock.yml +++ b/.github/workflows/weekly-issue-summary.lock.yml @@ -1563,6 +1563,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/pkg/cli/mcp_inspect.go b/pkg/cli/mcp_inspect.go index b579b0bd8d..e46426c60a 100644 --- a/pkg/cli/mcp_inspect.go +++ b/pkg/cli/mcp_inspect.go @@ -326,7 +326,6 @@ func writeSafeInputsFiles(dir string, safeInputsConfig *workflow.SafeInputsConfi content string }{ {"read_buffer.cjs", workflow.GetReadBufferScript()}, - {"mcp_server.cjs", workflow.GetMCPServerScript()}, {"mcp_http_transport.cjs", workflow.GetMCPHTTPTransportScript()}, {"safe_inputs_config_loader.cjs", workflow.GetSafeInputsConfigLoaderScript()}, {"mcp_server_core.cjs", workflow.GetMCPServerCoreScript()}, diff --git a/pkg/workflow/js.go b/pkg/workflow/js.go index e64b5164a7..a291352a6a 100644 --- a/pkg/workflow/js.go +++ b/pkg/workflow/js.go @@ -296,7 +296,6 @@ func GetJavaScriptSources() map[string]string { "update_pr_description_helpers.cjs": updatePRDescriptionHelpersScript, "read_buffer.cjs": readBufferScript, "mcp_server_core.cjs": mcpServerCoreScript, - "mcp_server.cjs": mcpServerScriptSource, "mcp_http_transport.cjs": mcpHTTPTransportScriptSource, "mcp_logger.cjs": mcpLoggerScriptSource, "safe_inputs_mcp_server.cjs": safeInputsMCPServerScript, @@ -777,11 +776,6 @@ func GetMCPServerCoreScript() string { return mcpServerCoreScript } -// GetMCPServerScript returns the embedded mcp_server.cjs script -func GetMCPServerScript() string { - return mcpServerScriptSource -} - // GetMCPHTTPTransportScript returns the embedded mcp_http_transport.cjs script func GetMCPHTTPTransportScript() string { return mcpHTTPTransportScriptSource diff --git a/pkg/workflow/js/mcp_http_transport.cjs b/pkg/workflow/js/mcp_http_transport.cjs index d5aeb92e04..b37a581e4d 100644 --- a/pkg/workflow/js/mcp_http_transport.cjs +++ b/pkg/workflow/js/mcp_http_transport.cjs @@ -20,7 +20,76 @@ const http = require("http"); const { randomUUID } = require("crypto"); -const { MCPServer } = require("./mcp_server.cjs"); +const { createServer, registerTool, handleRequest } = require("./mcp_server_core.cjs"); + +/** + * Simple MCP Server wrapper that provides a class-like interface + * compatible with the HTTP transport, backed by mcp_server_core functions. + */ +class MCPServer { + /** + * @param {Object} serverInfo - Server metadata + * @param {string} serverInfo.name - Server name + * @param {string} serverInfo.version - Server version + * @param {Object} [options] - Server options + * @param {Object} [options.capabilities] - Server capabilities + */ + constructor(serverInfo, options = {}) { + this._coreServer = createServer(serverInfo, options); + this.serverInfo = serverInfo; + this.capabilities = options.capabilities || { tools: {} }; + this.tools = new Map(); + this.transport = null; + this.initialized = false; + } + + /** + * Register a tool with the server + * @param {string} name - Tool name + * @param {string} description - Tool description + * @param {Object} inputSchema - JSON Schema for tool input + * @param {Function} handler - Async function that handles tool calls + */ + tool(name, description, inputSchema, handler) { + this.tools.set(name, { + name, + description, + inputSchema, + handler, + }); + // Also register with the core server + registerTool(this._coreServer, { + name, + description, + inputSchema, + handler, + }); + } + + /** + * Connect to a transport + * @param {any} transport - Transport instance (must have setServer and start methods) + */ + async connect(transport) { + this.transport = transport; + transport.setServer(this); + await transport.start(); + } + + /** + * Handle an incoming JSON-RPC request + * @param {Object} request - JSON-RPC request + * @returns {Promise} JSON-RPC response or null for notifications + */ + async handleRequest(request) { + // Track initialization state + if (request.method === "initialize") { + this.initialized = true; + } + // Delegate to core server's handleRequest function + return handleRequest(this._coreServer, request); + } +} /** * MCP HTTP Transport implementation diff --git a/pkg/workflow/js/mcp_server.cjs b/pkg/workflow/js/mcp_server.cjs deleted file mode 100644 index a6762f214a..0000000000 --- a/pkg/workflow/js/mcp_server.cjs +++ /dev/null @@ -1,191 +0,0 @@ -// @ts-check -/// - -/** - * MCP Server Implementation - * - * This module provides the MCPServer class for handling MCP (Model Context Protocol) - * tool registration and JSON-RPC 2.0 protocol handling. - * - * Features: - * - Tool registration with schema validation - * - JSON-RPC 2.0 protocol handling (initialize, tools/list, tools/call) - * - Transport-agnostic design (works with HTTP, stdio, etc.) - * - * References: - * - MCP Specification: https://spec.modelcontextprotocol.io - * - JSON-RPC 2.0: https://www.jsonrpc.org/specification - */ - -/** - * Simple MCP Server implementation that provides tool registration and protocol handling - */ -class MCPServer { - /** - * @param {Object} serverInfo - Server metadata - * @param {string} serverInfo.name - Server name - * @param {string} serverInfo.version - Server version - * @param {Object} [options] - Server options - * @param {Object} [options.capabilities] - Server capabilities - */ - constructor(serverInfo, options = {}) { - this.serverInfo = serverInfo; - this.capabilities = options.capabilities || { tools: {} }; - this.tools = new Map(); - this.transport = null; - this.initialized = false; - } - - /** - * Register a tool with the server - * @param {string} name - Tool name - * @param {string} description - Tool description - * @param {Object} inputSchema - JSON Schema for tool input - * @param {Function} handler - Async function that handles tool calls - */ - tool(name, description, inputSchema, handler) { - this.tools.set(name, { - name, - description, - inputSchema, - handler, - }); - } - - /** - * Connect to a transport - * @param {any} transport - Transport instance (must have setServer and start methods) - */ - async connect(transport) { - this.transport = transport; - transport.setServer(this); - await transport.start(); - } - - /** - * Handle initialize request - * @param {Object} params - Initialize parameters - * @returns {Object} Initialize result - */ - handleInitialize(params) { - this.initialized = true; - return { - protocolVersion: params.protocolVersion || "2024-11-05", - serverInfo: this.serverInfo, - capabilities: this.capabilities, - }; - } - - /** - * Handle tools/list request - * @returns {Object} Tools list result - */ - handleToolsList() { - const tools = Array.from(this.tools.values()).map(tool => ({ - name: tool.name, - description: tool.description, - inputSchema: tool.inputSchema, - })); - return { tools }; - } - - /** - * Handle tools/call request - * @param {Object} params - Call parameters - * @param {string} params.name - Tool name - * @param {Object} params.arguments - Tool arguments - * @returns {Promise} Tool call result - */ - async handleToolsCall(params) { - const tool = this.tools.get(params.name); - if (!tool) { - throw { - code: -32602, - message: `Tool '${params.name}' not found`, - }; - } - - try { - const result = await tool.handler(params.arguments || {}); - return result; - } catch (error) { - throw { - code: -32603, - message: error instanceof Error ? error.message : String(error), - }; - } - } - - /** - * Handle ping request - * @returns {Object} Empty ping result - */ - handlePing() { - return {}; - } - - /** - * Handle an incoming JSON-RPC request - * @param {Object} request - JSON-RPC request - * @returns {Promise} JSON-RPC response - */ - async handleRequest(request) { - const { id, method, params } = request; - - try { - // Handle notifications per JSON-RPC 2.0 spec: - // Requests without id field are notifications (no response) - // Note: id can be null for valid requests, so we check for field presence with "in" operator - // MCP notifications (methods starting with "notifications/") also omit the id field per convention - if (!("id" in request)) { - // No id field - this is a notification (no response) - return null; - } - - let result; - - switch (method) { - case "initialize": - result = this.handleInitialize(params || {}); - break; - - case "ping": - result = this.handlePing(); - break; - - case "tools/list": - result = this.handleToolsList(); - break; - - case "tools/call": - result = await this.handleToolsCall(params || {}); - break; - - default: - throw { - code: -32601, - message: `Method '${method}' not found`, - }; - } - - return { - jsonrpc: "2.0", - id, - result, - }; - } catch (error) { - return { - jsonrpc: "2.0", - id, - error: { - code: error.code || -32603, - message: error.message || "Internal error", - }, - }; - } - } -} - -module.exports = { - MCPServer, -}; diff --git a/pkg/workflow/js/mcp_server.test.cjs b/pkg/workflow/js/mcp_server.test.cjs deleted file mode 100644 index f127a98752..0000000000 --- a/pkg/workflow/js/mcp_server.test.cjs +++ /dev/null @@ -1,225 +0,0 @@ -import { describe, it, expect } from "vitest"; -import { MCPServer } from "./mcp_server.cjs"; - -/** - * Unit tests for mcp_server.cjs - * - * These tests validate the MCPServer class functionality independently - * of any transport implementation. - */ -describe("mcp_server.cjs", () => { - describe("MCPServer", () => { - it("should create a server with basic info", () => { - const server = new MCPServer({ name: "test-server", version: "1.0.0" }, { capabilities: { tools: {} } }); - - expect(server.serverInfo.name).toBe("test-server"); - expect(server.serverInfo.version).toBe("1.0.0"); - expect(server.capabilities.tools).toBeDefined(); - }); - - it("should create a server with default capabilities", () => { - const server = new MCPServer({ name: "test-server", version: "1.0.0" }); - - expect(server.capabilities.tools).toBeDefined(); - expect(server.initialized).toBe(false); - }); - - it("should register a tool", () => { - const server = new MCPServer({ name: "test-server", version: "1.0.0" }); - - server.tool( - "test_tool", - "A test tool", - { - type: "object", - properties: { - input: { type: "string" }, - }, - }, - async args => { - return { content: [{ type: "text", text: "result" }] }; - } - ); - - expect(server.tools.size).toBe(1); - expect(server.tools.has("test_tool")).toBe(true); - const tool = server.tools.get("test_tool"); - expect(tool.name).toBe("test_tool"); - expect(tool.description).toBe("A test tool"); - }); - - it("should handle initialize request", async () => { - const server = new MCPServer({ name: "test-server", version: "1.0.0" }); - - const response = await server.handleRequest({ - jsonrpc: "2.0", - id: 1, - method: "initialize", - params: { protocolVersion: "2024-11-05" }, - }); - - expect(response.jsonrpc).toBe("2.0"); - expect(response.id).toBe(1); - expect(response.result.protocolVersion).toBe("2024-11-05"); - expect(response.result.serverInfo.name).toBe("test-server"); - expect(server.initialized).toBe(true); - }); - - it("should handle tools/list request", async () => { - const server = new MCPServer({ name: "test-server", version: "1.0.0" }); - - server.tool("tool1", "First tool", {}, async () => ({ content: [] })); - server.tool("tool2", "Second tool", {}, async () => ({ content: [] })); - - const response = await server.handleRequest({ - jsonrpc: "2.0", - id: 2, - method: "tools/list", - }); - - expect(response.result.tools).toHaveLength(2); - expect(response.result.tools[0].name).toBe("tool1"); - expect(response.result.tools[1].name).toBe("tool2"); - }); - - it("should handle tools/call request", async () => { - const server = new MCPServer({ name: "test-server", version: "1.0.0" }); - - const mockHandler = async args => { - return { - content: [ - { - type: "text", - text: JSON.stringify({ echo: args.message }), - }, - ], - }; - }; - - server.tool("echo", "Echo tool", { type: "object" }, mockHandler); - - const response = await server.handleRequest({ - jsonrpc: "2.0", - id: 3, - method: "tools/call", - params: { - name: "echo", - arguments: { message: "hello" }, - }, - }); - - expect(response.result.content).toHaveLength(1); - expect(response.result.content[0].type).toBe("text"); - const result = JSON.parse(response.result.content[0].text); - expect(result.echo).toBe("hello"); - }); - - it("should return error for unknown tool", async () => { - const server = new MCPServer({ name: "test-server", version: "1.0.0" }); - - const response = await server.handleRequest({ - jsonrpc: "2.0", - id: 4, - method: "tools/call", - params: { - name: "unknown_tool", - arguments: {}, - }, - }); - - expect(response.error).toBeDefined(); - expect(response.error.code).toBe(-32602); - expect(response.error.message).toContain("not found"); - }); - - it("should return error for unknown method", async () => { - const server = new MCPServer({ name: "test-server", version: "1.0.0" }); - - const response = await server.handleRequest({ - jsonrpc: "2.0", - id: 5, - method: "unknown/method", - }); - - expect(response.error).toBeDefined(); - expect(response.error.code).toBe(-32601); - expect(response.error.message).toContain("not found"); - }); - - it("should handle tool handler errors", async () => { - const server = new MCPServer({ name: "test-server", version: "1.0.0" }); - - server.tool("error_tool", "Tool that throws", {}, async () => { - throw new Error("Test error"); - }); - - const response = await server.handleRequest({ - jsonrpc: "2.0", - id: 6, - method: "tools/call", - params: { - name: "error_tool", - arguments: {}, - }, - }); - - expect(response.error).toBeDefined(); - expect(response.error.code).toBe(-32603); - expect(response.error.message).toBe("Test error"); - }); - - it("should handle ping request", async () => { - const server = new MCPServer({ name: "test-server", version: "1.0.0" }); - - const response = await server.handleRequest({ - jsonrpc: "2.0", - id: 7, - method: "ping", - }); - - expect(response.jsonrpc).toBe("2.0"); - expect(response.id).toBe(7); - expect(response.result).toEqual({}); - }); - - it("should handle notifications/initialized without response", async () => { - const server = new MCPServer({ name: "test-server", version: "1.0.0" }); - - const response = await server.handleRequest({ - jsonrpc: "2.0", - method: "notifications/initialized", - // no id - this is a notification per JSON-RPC 2.0 spec - }); - - expect(response).toBeNull(); - }); - - it("should handle any notification without response (no id field)", async () => { - const server = new MCPServer({ name: "test-server", version: "1.0.0" }); - - const response = await server.handleRequest({ - jsonrpc: "2.0", - method: "some/custom/notification", - params: { data: "test" }, - // no id - this is a notification per JSON-RPC 2.0 spec - }); - - expect(response).toBeNull(); - }); - - it("should handle request with id: null as a valid request", async () => { - const server = new MCPServer({ name: "test-server", version: "1.0.0" }); - - const response = await server.handleRequest({ - jsonrpc: "2.0", - id: null, - method: "ping", - }); - - expect(response).not.toBeNull(); - expect(response.jsonrpc).toBe("2.0"); - expect(response.id).toBeNull(); - expect(response.result).toEqual({}); - }); - }); -}); diff --git a/pkg/workflow/js/mcp_server_core.cjs b/pkg/workflow/js/mcp_server_core.cjs index 1b8a3c6d52..8e8ddc22bf 100644 --- a/pkg/workflow/js/mcp_server_core.cjs +++ b/pkg/workflow/js/mcp_server_core.cjs @@ -479,7 +479,120 @@ function normalizeTool(name) { } /** - * Handle an incoming JSON-RPC message + * Handle an incoming JSON-RPC request and return a response (for HTTP transport) + * This function is compatible with the MCPServer class's handleRequest method. + * @param {MCPServer} server - The MCP server instance + * @param {Object} request - The incoming JSON-RPC request + * @param {Function} [defaultHandler] - Default handler for tools without a handler + * @returns {Promise} JSON-RPC response object, or null for notifications + */ +async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + + try { + // Handle notifications per JSON-RPC 2.0 spec: + // Requests without id field are notifications (no response) + // Note: id can be null for valid requests, so we check for field presence with "in" operator + if (!("id" in request)) { + // No id field - this is a notification (no response) + return null; + } + + let result; + + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + + // Use tool handler, or default handler, or error + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + + // Call handler and await the result (supports both sync and async handlers) + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + // Notifications don't need a response + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = /** @type {any} */ (error); + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } +} + +/** + * Handle an incoming JSON-RPC message (for stdio transport) * @param {MCPServer} server - The MCP server instance * @param {Object} req - The incoming request * @param {Function} [defaultHandler] - Default handler for tools without a handler @@ -628,6 +741,7 @@ module.exports = { createServer, registerTool, normalizeTool, + handleRequest, handleMessage, processReadBuffer, start, diff --git a/pkg/workflow/mcp_servers.go b/pkg/workflow/mcp_servers.go index 58de9b0c66..d6b91c6ed7 100644 --- a/pkg/workflow/mcp_servers.go +++ b/pkg/workflow/mcp_servers.go @@ -295,12 +295,6 @@ func (c *Compiler) generateMCPSetup(yaml *strings.Builder, tools map[string]any, } yaml.WriteString(" EOF_MCP_CORE\n") - yaml.WriteString(" cat > /tmp/gh-aw/safe-inputs/mcp_server.cjs << 'EOF_MCP_SERVER'\n") - for _, line := range FormatJavaScriptForYAML(GetMCPServerScript()) { - yaml.WriteString(line) - } - yaml.WriteString(" EOF_MCP_SERVER\n") - yaml.WriteString(" cat > /tmp/gh-aw/safe-inputs/mcp_http_transport.cjs << 'EOF_MCP_HTTP_TRANSPORT'\n") for _, line := range FormatJavaScriptForYAML(GetMCPHTTPTransportScript()) { yaml.WriteString(line) diff --git a/pkg/workflow/scripts.go b/pkg/workflow/scripts.go index 6f3c4334f3..3c9b264a75 100644 --- a/pkg/workflow/scripts.go +++ b/pkg/workflow/scripts.go @@ -125,9 +125,6 @@ var parseCopilotLogScriptSource string //go:embed js/mcp_logger.cjs var mcpLoggerScriptSource string -//go:embed js/mcp_server.cjs -var mcpServerScriptSource string - //go:embed js/mcp_http_transport.cjs var mcpHTTPTransportScriptSource string @@ -177,7 +174,6 @@ func init() { // MCP server and transport scripts DefaultScriptRegistry.Register("mcp_logger", mcpLoggerScriptSource) - DefaultScriptRegistry.Register("mcp_server", mcpServerScriptSource) DefaultScriptRegistry.Register("mcp_http_transport", mcpHTTPTransportScriptSource) // Template substitution scripts From 7307adedd172cf0043de0d25b57844c20ce813e6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 7 Dec 2025 21:33:24 +0000 Subject: [PATCH 4/6] Fix TypeScript error in mcp_server_core.cjs error handling Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> --- .github/workflows/ai-triage-campaign.lock.yml | 2 +- .github/workflows/archie.lock.yml | 2 +- .github/workflows/artifacts-summary.lock.yml | 2 +- .github/workflows/audit-workflows.lock.yml | 2 +- .github/workflows/blog-auditor.lock.yml | 2 +- .github/workflows/brave.lock.yml | 2 +- .github/workflows/breaking-change-checker.lock.yml | 2 +- .github/workflows/changeset.lock.yml | 2 +- .github/workflows/ci-doctor.lock.yml | 2 +- .github/workflows/cli-consistency-checker.lock.yml | 2 +- .github/workflows/cli-version-checker.lock.yml | 2 +- .github/workflows/cloclo.lock.yml | 2 +- .github/workflows/close-old-discussions.lock.yml | 2 +- .github/workflows/commit-changes-analyzer.lock.yml | 2 +- .github/workflows/copilot-agent-analysis.lock.yml | 2 +- .github/workflows/copilot-pr-merged-report.lock.yml | 4 ++-- .github/workflows/copilot-pr-nlp-analysis.lock.yml | 2 +- .github/workflows/copilot-pr-prompt-analysis.lock.yml | 2 +- .github/workflows/copilot-session-insights.lock.yml | 2 +- .github/workflows/craft.lock.yml | 2 +- .github/workflows/daily-assign-issue-to-user.lock.yml | 2 +- .github/workflows/daily-code-metrics.lock.yml | 2 +- .github/workflows/daily-copilot-token-report.lock.yml | 2 +- .github/workflows/daily-doc-updater.lock.yml | 2 +- .github/workflows/daily-fact.lock.yml | 2 +- .github/workflows/daily-file-diet.lock.yml | 2 +- .github/workflows/daily-firewall-report.lock.yml | 2 +- .github/workflows/daily-issues-report.lock.yml | 2 +- .github/workflows/daily-malicious-code-scan.lock.yml | 2 +- .github/workflows/daily-multi-device-docs-tester.lock.yml | 2 +- .github/workflows/daily-news.lock.yml | 2 +- .github/workflows/daily-performance-summary.lock.yml | 4 ++-- .github/workflows/daily-repo-chronicle.lock.yml | 2 +- .github/workflows/daily-workflow-updater.lock.yml | 2 +- .github/workflows/deep-report.lock.yml | 2 +- .github/workflows/dependabot-go-checker.lock.yml | 2 +- .github/workflows/dev-hawk.lock.yml | 2 +- .github/workflows/dev.lock.yml | 2 +- .github/workflows/developer-docs-consolidator.lock.yml | 2 +- .github/workflows/dictation-prompt.lock.yml | 2 +- .github/workflows/docs-noob-tester.lock.yml | 2 +- .github/workflows/duplicate-code-detector.lock.yml | 2 +- .github/workflows/example-workflow-analyzer.lock.yml | 2 +- .github/workflows/github-mcp-structural-analysis.lock.yml | 2 +- .github/workflows/github-mcp-tools-report.lock.yml | 2 +- .github/workflows/glossary-maintainer.lock.yml | 2 +- .github/workflows/go-fan.lock.yml | 2 +- .github/workflows/go-logger.lock.yml | 2 +- .github/workflows/go-pattern-detector.lock.yml | 2 +- .github/workflows/grumpy-reviewer.lock.yml | 2 +- .github/workflows/instructions-janitor.lock.yml | 2 +- .github/workflows/issue-arborist.lock.yml | 2 +- .github/workflows/issue-classifier.lock.yml | 2 +- .github/workflows/issue-monster.lock.yml | 2 +- .github/workflows/issue-triage-agent.lock.yml | 2 +- .github/workflows/lockfile-stats.lock.yml | 2 +- .github/workflows/mcp-inspector.lock.yml | 2 +- .github/workflows/mergefest.lock.yml | 2 +- .github/workflows/notion-issue-summary.lock.yml | 2 +- .github/workflows/org-health-report.lock.yml | 2 +- .github/workflows/pdf-summary.lock.yml | 2 +- .github/workflows/plan.lock.yml | 2 +- .github/workflows/poem-bot.lock.yml | 2 +- .github/workflows/pr-nitpick-reviewer.lock.yml | 2 +- .github/workflows/prompt-clustering-analysis.lock.yml | 2 +- .github/workflows/python-data-charts.lock.yml | 2 +- .github/workflows/q.lock.yml | 2 +- .github/workflows/release.lock.yml | 2 +- .github/workflows/repo-tree-map.lock.yml | 2 +- .github/workflows/repository-quality-improver.lock.yml | 2 +- .github/workflows/research.lock.yml | 2 +- .github/workflows/safe-output-health.lock.yml | 2 +- .github/workflows/schema-consistency-checker.lock.yml | 2 +- .github/workflows/scout.lock.yml | 2 +- .github/workflows/security-fix-pr.lock.yml | 2 +- .github/workflows/semantic-function-refactor.lock.yml | 2 +- .github/workflows/smoke-claude.lock.yml | 2 +- .github/workflows/smoke-codex.lock.yml | 2 +- .github/workflows/smoke-copilot-no-firewall.lock.yml | 2 +- .github/workflows/smoke-copilot-playwright.lock.yml | 4 ++-- .github/workflows/smoke-copilot-safe-inputs.lock.yml | 4 ++-- .github/workflows/smoke-copilot.lock.yml | 2 +- .github/workflows/smoke-detector.lock.yml | 2 +- .github/workflows/smoke-srt.lock.yml | 2 +- .github/workflows/spec-kit-executor.lock.yml | 2 +- .github/workflows/speckit-dispatcher.lock.yml | 2 +- .github/workflows/stale-repo-identifier.lock.yml | 2 +- .github/workflows/static-analysis-report.lock.yml | 2 +- .github/workflows/super-linter.lock.yml | 2 +- .github/workflows/technical-doc-writer.lock.yml | 2 +- .github/workflows/test-discussion-expires.lock.yml | 2 +- .github/workflows/test-python-safe-input.lock.yml | 4 ++-- .github/workflows/tidy.lock.yml | 2 +- .github/workflows/typist.lock.yml | 2 +- .github/workflows/unbloat-docs.lock.yml | 2 +- .github/workflows/video-analyzer.lock.yml | 2 +- .github/workflows/weekly-issue-summary.lock.yml | 2 +- pkg/workflow/js/mcp_server_core.cjs | 2 +- 98 files changed, 103 insertions(+), 103 deletions(-) diff --git a/.github/workflows/ai-triage-campaign.lock.yml b/.github/workflows/ai-triage-campaign.lock.yml index 32ea2409a3..ba8d64d9df 100644 --- a/.github/workflows/ai-triage-campaign.lock.yml +++ b/.github/workflows/ai-triage-campaign.lock.yml @@ -1053,7 +1053,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/archie.lock.yml b/.github/workflows/archie.lock.yml index eec1303fe6..e1a03df643 100644 --- a/.github/workflows/archie.lock.yml +++ b/.github/workflows/archie.lock.yml @@ -2540,7 +2540,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/artifacts-summary.lock.yml b/.github/workflows/artifacts-summary.lock.yml index e3c8b085b0..6b67621bf1 100644 --- a/.github/workflows/artifacts-summary.lock.yml +++ b/.github/workflows/artifacts-summary.lock.yml @@ -1124,7 +1124,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/audit-workflows.lock.yml b/.github/workflows/audit-workflows.lock.yml index f7fc807667..93fdc21e07 100644 --- a/.github/workflows/audit-workflows.lock.yml +++ b/.github/workflows/audit-workflows.lock.yml @@ -1941,7 +1941,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/blog-auditor.lock.yml b/.github/workflows/blog-auditor.lock.yml index 2d0b7abc44..a18c690335 100644 --- a/.github/workflows/blog-auditor.lock.yml +++ b/.github/workflows/blog-auditor.lock.yml @@ -1439,7 +1439,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/brave.lock.yml b/.github/workflows/brave.lock.yml index 25fd4c9467..2523a7c889 100644 --- a/.github/workflows/brave.lock.yml +++ b/.github/workflows/brave.lock.yml @@ -2425,7 +2425,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/breaking-change-checker.lock.yml b/.github/workflows/breaking-change-checker.lock.yml index 9f81bfb7a1..cc2ead0aac 100644 --- a/.github/workflows/breaking-change-checker.lock.yml +++ b/.github/workflows/breaking-change-checker.lock.yml @@ -1171,7 +1171,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/changeset.lock.yml b/.github/workflows/changeset.lock.yml index 88b99a88ed..7d684ecd6b 100644 --- a/.github/workflows/changeset.lock.yml +++ b/.github/workflows/changeset.lock.yml @@ -2044,7 +2044,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/ci-doctor.lock.yml b/.github/workflows/ci-doctor.lock.yml index f0a99b1f5c..55d9132e9d 100644 --- a/.github/workflows/ci-doctor.lock.yml +++ b/.github/workflows/ci-doctor.lock.yml @@ -1858,7 +1858,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/cli-consistency-checker.lock.yml b/.github/workflows/cli-consistency-checker.lock.yml index 222eb33a32..06d9e90083 100644 --- a/.github/workflows/cli-consistency-checker.lock.yml +++ b/.github/workflows/cli-consistency-checker.lock.yml @@ -1172,7 +1172,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/cli-version-checker.lock.yml b/.github/workflows/cli-version-checker.lock.yml index c083e432a2..44b1dbe846 100644 --- a/.github/workflows/cli-version-checker.lock.yml +++ b/.github/workflows/cli-version-checker.lock.yml @@ -1445,7 +1445,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/cloclo.lock.yml b/.github/workflows/cloclo.lock.yml index 7bca2845fe..99de4ca255 100644 --- a/.github/workflows/cloclo.lock.yml +++ b/.github/workflows/cloclo.lock.yml @@ -2845,7 +2845,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/close-old-discussions.lock.yml b/.github/workflows/close-old-discussions.lock.yml index de9a19630c..a56895164d 100644 --- a/.github/workflows/close-old-discussions.lock.yml +++ b/.github/workflows/close-old-discussions.lock.yml @@ -1339,7 +1339,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/commit-changes-analyzer.lock.yml b/.github/workflows/commit-changes-analyzer.lock.yml index d403a9a1e7..af5f2eb360 100644 --- a/.github/workflows/commit-changes-analyzer.lock.yml +++ b/.github/workflows/commit-changes-analyzer.lock.yml @@ -1398,7 +1398,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/copilot-agent-analysis.lock.yml b/.github/workflows/copilot-agent-analysis.lock.yml index 2a56e525ee..c0008a01d1 100644 --- a/.github/workflows/copilot-agent-analysis.lock.yml +++ b/.github/workflows/copilot-agent-analysis.lock.yml @@ -1753,7 +1753,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/copilot-pr-merged-report.lock.yml b/.github/workflows/copilot-pr-merged-report.lock.yml index 396f57071b..178b9e1d36 100644 --- a/.github/workflows/copilot-pr-merged-report.lock.yml +++ b/.github/workflows/copilot-pr-merged-report.lock.yml @@ -1302,7 +1302,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, @@ -2320,7 +2320,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/copilot-pr-nlp-analysis.lock.yml b/.github/workflows/copilot-pr-nlp-analysis.lock.yml index 0e01e8fc81..8fce391757 100644 --- a/.github/workflows/copilot-pr-nlp-analysis.lock.yml +++ b/.github/workflows/copilot-pr-nlp-analysis.lock.yml @@ -1968,7 +1968,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/copilot-pr-prompt-analysis.lock.yml b/.github/workflows/copilot-pr-prompt-analysis.lock.yml index 79ac0a37e4..76b6bcc3be 100644 --- a/.github/workflows/copilot-pr-prompt-analysis.lock.yml +++ b/.github/workflows/copilot-pr-prompt-analysis.lock.yml @@ -1468,7 +1468,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/copilot-session-insights.lock.yml b/.github/workflows/copilot-session-insights.lock.yml index 8da52394aa..472092b661 100644 --- a/.github/workflows/copilot-session-insights.lock.yml +++ b/.github/workflows/copilot-session-insights.lock.yml @@ -2483,7 +2483,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/craft.lock.yml b/.github/workflows/craft.lock.yml index 7459968c01..3879704a53 100644 --- a/.github/workflows/craft.lock.yml +++ b/.github/workflows/craft.lock.yml @@ -2635,7 +2635,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-assign-issue-to-user.lock.yml b/.github/workflows/daily-assign-issue-to-user.lock.yml index 6e66fd0edc..a77ebccbfc 100644 --- a/.github/workflows/daily-assign-issue-to-user.lock.yml +++ b/.github/workflows/daily-assign-issue-to-user.lock.yml @@ -1616,7 +1616,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-code-metrics.lock.yml b/.github/workflows/daily-code-metrics.lock.yml index 74cef0b01f..506a5ecffc 100644 --- a/.github/workflows/daily-code-metrics.lock.yml +++ b/.github/workflows/daily-code-metrics.lock.yml @@ -1985,7 +1985,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-copilot-token-report.lock.yml b/.github/workflows/daily-copilot-token-report.lock.yml index 0beeeeaa3e..530a397d01 100644 --- a/.github/workflows/daily-copilot-token-report.lock.yml +++ b/.github/workflows/daily-copilot-token-report.lock.yml @@ -2036,7 +2036,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-doc-updater.lock.yml b/.github/workflows/daily-doc-updater.lock.yml index 74cf3cb4ba..bc3d277f5a 100644 --- a/.github/workflows/daily-doc-updater.lock.yml +++ b/.github/workflows/daily-doc-updater.lock.yml @@ -1297,7 +1297,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-fact.lock.yml b/.github/workflows/daily-fact.lock.yml index c9f10c630e..f06db10759 100644 --- a/.github/workflows/daily-fact.lock.yml +++ b/.github/workflows/daily-fact.lock.yml @@ -1625,7 +1625,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-file-diet.lock.yml b/.github/workflows/daily-file-diet.lock.yml index 02e5e2e473..2f3d1dbb11 100644 --- a/.github/workflows/daily-file-diet.lock.yml +++ b/.github/workflows/daily-file-diet.lock.yml @@ -1322,7 +1322,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-firewall-report.lock.yml b/.github/workflows/daily-firewall-report.lock.yml index 8c4867d313..a18306397a 100644 --- a/.github/workflows/daily-firewall-report.lock.yml +++ b/.github/workflows/daily-firewall-report.lock.yml @@ -1737,7 +1737,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-issues-report.lock.yml b/.github/workflows/daily-issues-report.lock.yml index 918786dd61..17886667cb 100644 --- a/.github/workflows/daily-issues-report.lock.yml +++ b/.github/workflows/daily-issues-report.lock.yml @@ -2130,7 +2130,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-malicious-code-scan.lock.yml b/.github/workflows/daily-malicious-code-scan.lock.yml index bce20ae589..1b3181ee39 100644 --- a/.github/workflows/daily-malicious-code-scan.lock.yml +++ b/.github/workflows/daily-malicious-code-scan.lock.yml @@ -1302,7 +1302,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-multi-device-docs-tester.lock.yml b/.github/workflows/daily-multi-device-docs-tester.lock.yml index 0d971916af..4482a4f3f3 100644 --- a/.github/workflows/daily-multi-device-docs-tester.lock.yml +++ b/.github/workflows/daily-multi-device-docs-tester.lock.yml @@ -1254,7 +1254,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-news.lock.yml b/.github/workflows/daily-news.lock.yml index 6ced91ff2e..b19f911600 100644 --- a/.github/workflows/daily-news.lock.yml +++ b/.github/workflows/daily-news.lock.yml @@ -2055,7 +2055,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-performance-summary.lock.yml b/.github/workflows/daily-performance-summary.lock.yml index d59e4d1b9e..5d2e2613d3 100644 --- a/.github/workflows/daily-performance-summary.lock.yml +++ b/.github/workflows/daily-performance-summary.lock.yml @@ -1892,7 +1892,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, @@ -2910,7 +2910,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-repo-chronicle.lock.yml b/.github/workflows/daily-repo-chronicle.lock.yml index 069ba5c4bb..5ded285b7d 100644 --- a/.github/workflows/daily-repo-chronicle.lock.yml +++ b/.github/workflows/daily-repo-chronicle.lock.yml @@ -1740,7 +1740,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-workflow-updater.lock.yml b/.github/workflows/daily-workflow-updater.lock.yml index a2d826fa72..a40fa96dde 100644 --- a/.github/workflows/daily-workflow-updater.lock.yml +++ b/.github/workflows/daily-workflow-updater.lock.yml @@ -1163,7 +1163,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/deep-report.lock.yml b/.github/workflows/deep-report.lock.yml index 3914ff29e4..1d05a2be95 100644 --- a/.github/workflows/deep-report.lock.yml +++ b/.github/workflows/deep-report.lock.yml @@ -1612,7 +1612,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/dependabot-go-checker.lock.yml b/.github/workflows/dependabot-go-checker.lock.yml index 18011b3566..c478aca044 100644 --- a/.github/workflows/dependabot-go-checker.lock.yml +++ b/.github/workflows/dependabot-go-checker.lock.yml @@ -1475,7 +1475,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/dev-hawk.lock.yml b/.github/workflows/dev-hawk.lock.yml index 869218239a..8bb07fc420 100644 --- a/.github/workflows/dev-hawk.lock.yml +++ b/.github/workflows/dev-hawk.lock.yml @@ -1689,7 +1689,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/dev.lock.yml b/.github/workflows/dev.lock.yml index e8d7e2f524..8df9cd8965 100644 --- a/.github/workflows/dev.lock.yml +++ b/.github/workflows/dev.lock.yml @@ -815,7 +815,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/developer-docs-consolidator.lock.yml b/.github/workflows/developer-docs-consolidator.lock.yml index d76ca5924b..21a3c17aff 100644 --- a/.github/workflows/developer-docs-consolidator.lock.yml +++ b/.github/workflows/developer-docs-consolidator.lock.yml @@ -1873,7 +1873,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/dictation-prompt.lock.yml b/.github/workflows/dictation-prompt.lock.yml index 64a46425f3..5c946d49ee 100644 --- a/.github/workflows/dictation-prompt.lock.yml +++ b/.github/workflows/dictation-prompt.lock.yml @@ -1149,7 +1149,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/docs-noob-tester.lock.yml b/.github/workflows/docs-noob-tester.lock.yml index 76ed9cf778..ffe85fd2dc 100644 --- a/.github/workflows/docs-noob-tester.lock.yml +++ b/.github/workflows/docs-noob-tester.lock.yml @@ -1179,7 +1179,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/duplicate-code-detector.lock.yml b/.github/workflows/duplicate-code-detector.lock.yml index 0879c8ef8b..409b7f37fc 100644 --- a/.github/workflows/duplicate-code-detector.lock.yml +++ b/.github/workflows/duplicate-code-detector.lock.yml @@ -1227,7 +1227,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/example-workflow-analyzer.lock.yml b/.github/workflows/example-workflow-analyzer.lock.yml index 26c7b0e310..ef81ac49a6 100644 --- a/.github/workflows/example-workflow-analyzer.lock.yml +++ b/.github/workflows/example-workflow-analyzer.lock.yml @@ -1196,7 +1196,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/github-mcp-structural-analysis.lock.yml b/.github/workflows/github-mcp-structural-analysis.lock.yml index f7445078e9..df0781bb8c 100644 --- a/.github/workflows/github-mcp-structural-analysis.lock.yml +++ b/.github/workflows/github-mcp-structural-analysis.lock.yml @@ -1840,7 +1840,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/github-mcp-tools-report.lock.yml b/.github/workflows/github-mcp-tools-report.lock.yml index 49984304eb..f0da6f97e9 100644 --- a/.github/workflows/github-mcp-tools-report.lock.yml +++ b/.github/workflows/github-mcp-tools-report.lock.yml @@ -1724,7 +1724,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/glossary-maintainer.lock.yml b/.github/workflows/glossary-maintainer.lock.yml index 654b3d0762..e1bcbe530d 100644 --- a/.github/workflows/glossary-maintainer.lock.yml +++ b/.github/workflows/glossary-maintainer.lock.yml @@ -1663,7 +1663,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/go-fan.lock.yml b/.github/workflows/go-fan.lock.yml index f058acc2b5..f3c3b73d5d 100644 --- a/.github/workflows/go-fan.lock.yml +++ b/.github/workflows/go-fan.lock.yml @@ -1499,7 +1499,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/go-logger.lock.yml b/.github/workflows/go-logger.lock.yml index 03565b0742..da083c2fe6 100644 --- a/.github/workflows/go-logger.lock.yml +++ b/.github/workflows/go-logger.lock.yml @@ -1425,7 +1425,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/go-pattern-detector.lock.yml b/.github/workflows/go-pattern-detector.lock.yml index be20e2bea0..509d9fae13 100644 --- a/.github/workflows/go-pattern-detector.lock.yml +++ b/.github/workflows/go-pattern-detector.lock.yml @@ -1284,7 +1284,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/grumpy-reviewer.lock.yml b/.github/workflows/grumpy-reviewer.lock.yml index 6fa871fca9..798bee4160 100644 --- a/.github/workflows/grumpy-reviewer.lock.yml +++ b/.github/workflows/grumpy-reviewer.lock.yml @@ -2557,7 +2557,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/instructions-janitor.lock.yml b/.github/workflows/instructions-janitor.lock.yml index ef76a15d22..108dcced98 100644 --- a/.github/workflows/instructions-janitor.lock.yml +++ b/.github/workflows/instructions-janitor.lock.yml @@ -1294,7 +1294,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/issue-arborist.lock.yml b/.github/workflows/issue-arborist.lock.yml index 2187c028e3..79933f384f 100644 --- a/.github/workflows/issue-arborist.lock.yml +++ b/.github/workflows/issue-arborist.lock.yml @@ -1273,7 +1273,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/issue-classifier.lock.yml b/.github/workflows/issue-classifier.lock.yml index cf88d420dc..6836fd3c82 100644 --- a/.github/workflows/issue-classifier.lock.yml +++ b/.github/workflows/issue-classifier.lock.yml @@ -2282,7 +2282,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/issue-monster.lock.yml b/.github/workflows/issue-monster.lock.yml index 816a71f204..df5eba835c 100644 --- a/.github/workflows/issue-monster.lock.yml +++ b/.github/workflows/issue-monster.lock.yml @@ -1833,7 +1833,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/issue-triage-agent.lock.yml b/.github/workflows/issue-triage-agent.lock.yml index 98b9bf7236..544c44bc97 100644 --- a/.github/workflows/issue-triage-agent.lock.yml +++ b/.github/workflows/issue-triage-agent.lock.yml @@ -1470,7 +1470,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/lockfile-stats.lock.yml b/.github/workflows/lockfile-stats.lock.yml index c8debad6cf..70077cde25 100644 --- a/.github/workflows/lockfile-stats.lock.yml +++ b/.github/workflows/lockfile-stats.lock.yml @@ -1519,7 +1519,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/mcp-inspector.lock.yml b/.github/workflows/mcp-inspector.lock.yml index b680ff2140..b9545141ad 100644 --- a/.github/workflows/mcp-inspector.lock.yml +++ b/.github/workflows/mcp-inspector.lock.yml @@ -1359,7 +1359,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/mergefest.lock.yml b/.github/workflows/mergefest.lock.yml index b3c100403d..3289871887 100644 --- a/.github/workflows/mergefest.lock.yml +++ b/.github/workflows/mergefest.lock.yml @@ -1702,7 +1702,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/notion-issue-summary.lock.yml b/.github/workflows/notion-issue-summary.lock.yml index f6d0e83b19..f0717024d3 100644 --- a/.github/workflows/notion-issue-summary.lock.yml +++ b/.github/workflows/notion-issue-summary.lock.yml @@ -938,7 +938,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/org-health-report.lock.yml b/.github/workflows/org-health-report.lock.yml index 0ace008b06..b44cbe099e 100644 --- a/.github/workflows/org-health-report.lock.yml +++ b/.github/workflows/org-health-report.lock.yml @@ -1948,7 +1948,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/pdf-summary.lock.yml b/.github/workflows/pdf-summary.lock.yml index d8354d479d..e2246b9919 100644 --- a/.github/workflows/pdf-summary.lock.yml +++ b/.github/workflows/pdf-summary.lock.yml @@ -2542,7 +2542,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/plan.lock.yml b/.github/workflows/plan.lock.yml index b9e7ba724f..4b6b1a48b3 100644 --- a/.github/workflows/plan.lock.yml +++ b/.github/workflows/plan.lock.yml @@ -1944,7 +1944,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/poem-bot.lock.yml b/.github/workflows/poem-bot.lock.yml index 586452f5a2..9a31c148f4 100644 --- a/.github/workflows/poem-bot.lock.yml +++ b/.github/workflows/poem-bot.lock.yml @@ -3672,7 +3672,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/pr-nitpick-reviewer.lock.yml b/.github/workflows/pr-nitpick-reviewer.lock.yml index b1ffde16b9..1630723368 100644 --- a/.github/workflows/pr-nitpick-reviewer.lock.yml +++ b/.github/workflows/pr-nitpick-reviewer.lock.yml @@ -2593,7 +2593,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/prompt-clustering-analysis.lock.yml b/.github/workflows/prompt-clustering-analysis.lock.yml index eb88c0550f..1c9a54f503 100644 --- a/.github/workflows/prompt-clustering-analysis.lock.yml +++ b/.github/workflows/prompt-clustering-analysis.lock.yml @@ -2205,7 +2205,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/python-data-charts.lock.yml b/.github/workflows/python-data-charts.lock.yml index 76097c892c..486a1fcb20 100644 --- a/.github/workflows/python-data-charts.lock.yml +++ b/.github/workflows/python-data-charts.lock.yml @@ -2041,7 +2041,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/q.lock.yml b/.github/workflows/q.lock.yml index 8444f28d09..3a4a3de366 100644 --- a/.github/workflows/q.lock.yml +++ b/.github/workflows/q.lock.yml @@ -2860,7 +2860,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/release.lock.yml b/.github/workflows/release.lock.yml index f0b6c3cd00..1f2c1681df 100644 --- a/.github/workflows/release.lock.yml +++ b/.github/workflows/release.lock.yml @@ -1291,7 +1291,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/repo-tree-map.lock.yml b/.github/workflows/repo-tree-map.lock.yml index 8f26a262c4..fb66284500 100644 --- a/.github/workflows/repo-tree-map.lock.yml +++ b/.github/workflows/repo-tree-map.lock.yml @@ -1177,7 +1177,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/repository-quality-improver.lock.yml b/.github/workflows/repository-quality-improver.lock.yml index 5cbbe9d974..8d5168f99f 100644 --- a/.github/workflows/repository-quality-improver.lock.yml +++ b/.github/workflows/repository-quality-improver.lock.yml @@ -1638,7 +1638,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/research.lock.yml b/.github/workflows/research.lock.yml index 75e35b55e2..6cba01d63f 100644 --- a/.github/workflows/research.lock.yml +++ b/.github/workflows/research.lock.yml @@ -1099,7 +1099,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/safe-output-health.lock.yml b/.github/workflows/safe-output-health.lock.yml index a4bc56a9c6..b7e9185399 100644 --- a/.github/workflows/safe-output-health.lock.yml +++ b/.github/workflows/safe-output-health.lock.yml @@ -1644,7 +1644,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/schema-consistency-checker.lock.yml b/.github/workflows/schema-consistency-checker.lock.yml index 5f5f8ff2aa..bc2524a6d4 100644 --- a/.github/workflows/schema-consistency-checker.lock.yml +++ b/.github/workflows/schema-consistency-checker.lock.yml @@ -1529,7 +1529,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/scout.lock.yml b/.github/workflows/scout.lock.yml index 6c93d3b352..fe82319004 100644 --- a/.github/workflows/scout.lock.yml +++ b/.github/workflows/scout.lock.yml @@ -2846,7 +2846,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/security-fix-pr.lock.yml b/.github/workflows/security-fix-pr.lock.yml index 2625a45edd..472ee4f655 100644 --- a/.github/workflows/security-fix-pr.lock.yml +++ b/.github/workflows/security-fix-pr.lock.yml @@ -1271,7 +1271,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/semantic-function-refactor.lock.yml b/.github/workflows/semantic-function-refactor.lock.yml index a18145fbe9..550f869db5 100644 --- a/.github/workflows/semantic-function-refactor.lock.yml +++ b/.github/workflows/semantic-function-refactor.lock.yml @@ -1673,7 +1673,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-claude.lock.yml b/.github/workflows/smoke-claude.lock.yml index 309db46b28..b9be9c1bee 100644 --- a/.github/workflows/smoke-claude.lock.yml +++ b/.github/workflows/smoke-claude.lock.yml @@ -2957,7 +2957,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-codex.lock.yml b/.github/workflows/smoke-codex.lock.yml index fec5e11c13..e7e8d02d2e 100644 --- a/.github/workflows/smoke-codex.lock.yml +++ b/.github/workflows/smoke-codex.lock.yml @@ -2727,7 +2727,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-copilot-no-firewall.lock.yml b/.github/workflows/smoke-copilot-no-firewall.lock.yml index fae72ff036..9114dcbae2 100644 --- a/.github/workflows/smoke-copilot-no-firewall.lock.yml +++ b/.github/workflows/smoke-copilot-no-firewall.lock.yml @@ -2800,7 +2800,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-copilot-playwright.lock.yml b/.github/workflows/smoke-copilot-playwright.lock.yml index 56433881b0..101c117747 100644 --- a/.github/workflows/smoke-copilot-playwright.lock.yml +++ b/.github/workflows/smoke-copilot-playwright.lock.yml @@ -2805,7 +2805,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, @@ -3823,7 +3823,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-copilot-safe-inputs.lock.yml b/.github/workflows/smoke-copilot-safe-inputs.lock.yml index 338dd4674f..fb29881cd1 100644 --- a/.github/workflows/smoke-copilot-safe-inputs.lock.yml +++ b/.github/workflows/smoke-copilot-safe-inputs.lock.yml @@ -2705,7 +2705,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, @@ -3723,7 +3723,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-copilot.lock.yml b/.github/workflows/smoke-copilot.lock.yml index 7edd54c011..39c31ab0af 100644 --- a/.github/workflows/smoke-copilot.lock.yml +++ b/.github/workflows/smoke-copilot.lock.yml @@ -2714,7 +2714,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-detector.lock.yml b/.github/workflows/smoke-detector.lock.yml index ceaaf59a24..0da6f73ce3 100644 --- a/.github/workflows/smoke-detector.lock.yml +++ b/.github/workflows/smoke-detector.lock.yml @@ -2566,7 +2566,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-srt.lock.yml b/.github/workflows/smoke-srt.lock.yml index 68cc65a608..4a896071ee 100644 --- a/.github/workflows/smoke-srt.lock.yml +++ b/.github/workflows/smoke-srt.lock.yml @@ -969,7 +969,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/spec-kit-executor.lock.yml b/.github/workflows/spec-kit-executor.lock.yml index 2adbcc5214..44b3c581a1 100644 --- a/.github/workflows/spec-kit-executor.lock.yml +++ b/.github/workflows/spec-kit-executor.lock.yml @@ -1291,7 +1291,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/speckit-dispatcher.lock.yml b/.github/workflows/speckit-dispatcher.lock.yml index 3c28ab8344..35964e6667 100644 --- a/.github/workflows/speckit-dispatcher.lock.yml +++ b/.github/workflows/speckit-dispatcher.lock.yml @@ -2705,7 +2705,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/stale-repo-identifier.lock.yml b/.github/workflows/stale-repo-identifier.lock.yml index 62fc176073..cfe10bcbd1 100644 --- a/.github/workflows/stale-repo-identifier.lock.yml +++ b/.github/workflows/stale-repo-identifier.lock.yml @@ -2038,7 +2038,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/static-analysis-report.lock.yml b/.github/workflows/static-analysis-report.lock.yml index e90ea11700..610da52420 100644 --- a/.github/workflows/static-analysis-report.lock.yml +++ b/.github/workflows/static-analysis-report.lock.yml @@ -1553,7 +1553,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/super-linter.lock.yml b/.github/workflows/super-linter.lock.yml index 55661d972e..6297c83e1c 100644 --- a/.github/workflows/super-linter.lock.yml +++ b/.github/workflows/super-linter.lock.yml @@ -1293,7 +1293,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/technical-doc-writer.lock.yml b/.github/workflows/technical-doc-writer.lock.yml index 8992ffe21e..fdc9bfda16 100644 --- a/.github/workflows/technical-doc-writer.lock.yml +++ b/.github/workflows/technical-doc-writer.lock.yml @@ -2151,7 +2151,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/test-discussion-expires.lock.yml b/.github/workflows/test-discussion-expires.lock.yml index ea13025d8d..fdca5b2e57 100644 --- a/.github/workflows/test-discussion-expires.lock.yml +++ b/.github/workflows/test-discussion-expires.lock.yml @@ -970,7 +970,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/test-python-safe-input.lock.yml b/.github/workflows/test-python-safe-input.lock.yml index 0d918d384d..ecd0fd6b8a 100644 --- a/.github/workflows/test-python-safe-input.lock.yml +++ b/.github/workflows/test-python-safe-input.lock.yml @@ -1074,7 +1074,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, @@ -2092,7 +2092,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/tidy.lock.yml b/.github/workflows/tidy.lock.yml index e6c750b967..9b74c2dc50 100644 --- a/.github/workflows/tidy.lock.yml +++ b/.github/workflows/tidy.lock.yml @@ -1581,7 +1581,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/typist.lock.yml b/.github/workflows/typist.lock.yml index 83f0b8a8fe..1464e08ea6 100644 --- a/.github/workflows/typist.lock.yml +++ b/.github/workflows/typist.lock.yml @@ -1658,7 +1658,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/unbloat-docs.lock.yml b/.github/workflows/unbloat-docs.lock.yml index df2269f024..c9f45dfd5c 100644 --- a/.github/workflows/unbloat-docs.lock.yml +++ b/.github/workflows/unbloat-docs.lock.yml @@ -2608,7 +2608,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/video-analyzer.lock.yml b/.github/workflows/video-analyzer.lock.yml index 6ca6918214..fc971e6876 100644 --- a/.github/workflows/video-analyzer.lock.yml +++ b/.github/workflows/video-analyzer.lock.yml @@ -1285,7 +1285,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/.github/workflows/weekly-issue-summary.lock.yml b/.github/workflows/weekly-issue-summary.lock.yml index 62d8c9e4d7..92a9aa5aec 100644 --- a/.github/workflows/weekly-issue-summary.lock.yml +++ b/.github/workflows/weekly-issue-summary.lock.yml @@ -1642,7 +1642,7 @@ jobs: result, }; } catch (error) { - const err = (error); + const err = error; return { jsonrpc: "2.0", id, diff --git a/pkg/workflow/js/mcp_server_core.cjs b/pkg/workflow/js/mcp_server_core.cjs index 8e8ddc22bf..824e8bbd6e 100644 --- a/pkg/workflow/js/mcp_server_core.cjs +++ b/pkg/workflow/js/mcp_server_core.cjs @@ -579,7 +579,7 @@ async function handleRequest(server, request, defaultHandler) { result, }; } catch (error) { - const err = /** @type {any} */ (error); + const err = /** @type {any} */ error; return { jsonrpc: "2.0", id, From 5c94a1b7ee96bf56a7b4f95ee534b08e459e483f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 7 Dec 2025 22:15:45 +0000 Subject: [PATCH 5/6] Merge main, recompile, format, lint, and fix TypeScript error - Merged main branch successfully - Recompiled all workflow files (102 workflows) - Ran formatting and linting (all passed) - Fixed TypeScript error in mcp_server_core.cjs error handling - All core MCP tests passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/workflows/ai-triage-campaign.lock.yml | 2 +- .github/workflows/archie.lock.yml | 2 +- .github/workflows/artifacts-summary.lock.yml | 2 +- .github/workflows/audit-workflows.lock.yml | 2 +- .github/workflows/blog-auditor.lock.yml | 2 +- .github/workflows/brave.lock.yml | 2 +- .../breaking-change-checker.lock.yml | 2 +- .github/workflows/changeset.lock.yml | 2 +- .github/workflows/ci-doctor.lock.yml | 2 +- .../cli-consistency-checker.lock.yml | 2 +- .../workflows/cli-version-checker.lock.yml | 2 +- .github/workflows/cloclo.lock.yml | 2 +- .../workflows/close-old-discussions.lock.yml | 2 +- .../commit-changes-analyzer.lock.yml | 2 +- .../workflows/copilot-agent-analysis.lock.yml | 2 +- .../copilot-pr-merged-report.lock.yml | 4 +- .../copilot-pr-nlp-analysis.lock.yml | 2 +- .../copilot-pr-prompt-analysis.lock.yml | 2 +- .../copilot-session-insights.lock.yml | 2 +- .github/workflows/craft.lock.yml | 2 +- .../daily-assign-issue-to-user.lock.yml | 2 +- .github/workflows/daily-code-metrics.lock.yml | 2 +- .../daily-copilot-token-report.lock.yml | 2 +- .github/workflows/daily-doc-updater.lock.yml | 2 +- .github/workflows/daily-fact.lock.yml | 2 +- .github/workflows/daily-file-diet.lock.yml | 2 +- .../workflows/daily-firewall-report.lock.yml | 2 +- .../workflows/daily-issues-report.lock.yml | 2 +- .../daily-malicious-code-scan.lock.yml | 2 +- .../daily-multi-device-docs-tester.lock.yml | 2 +- .github/workflows/daily-news.lock.yml | 2 +- .../daily-performance-summary.lock.yml | 4 +- .../workflows/daily-repo-chronicle.lock.yml | 2 +- .github/workflows/daily-team-status.lock.yml | 90 +++++++++++++++++++ .../workflows/daily-workflow-updater.lock.yml | 2 +- .github/workflows/deep-report.lock.yml | 2 +- .../workflows/dependabot-go-checker.lock.yml | 2 +- .github/workflows/dev-hawk.lock.yml | 2 +- .github/workflows/dev.lock.yml | 2 +- .../developer-docs-consolidator.lock.yml | 2 +- .github/workflows/dictation-prompt.lock.yml | 2 +- .github/workflows/docs-noob-tester.lock.yml | 2 +- .../duplicate-code-detector.lock.yml | 2 +- .../example-workflow-analyzer.lock.yml | 2 +- .../github-mcp-structural-analysis.lock.yml | 2 +- .../github-mcp-tools-report.lock.yml | 2 +- .../workflows/glossary-maintainer.lock.yml | 2 +- .github/workflows/go-fan.lock.yml | 2 +- .github/workflows/go-logger.lock.yml | 2 +- .../workflows/go-pattern-detector.lock.yml | 2 +- .github/workflows/grumpy-reviewer.lock.yml | 2 +- .../workflows/instructions-janitor.lock.yml | 2 +- .github/workflows/issue-arborist.lock.yml | 2 +- .github/workflows/issue-classifier.lock.yml | 2 +- .github/workflows/issue-monster.lock.yml | 2 +- .github/workflows/issue-triage-agent.lock.yml | 2 +- .github/workflows/lockfile-stats.lock.yml | 2 +- .github/workflows/mcp-inspector.lock.yml | 2 +- .github/workflows/mergefest.lock.yml | 2 +- .../workflows/notion-issue-summary.lock.yml | 2 +- .github/workflows/org-health-report.lock.yml | 2 +- .github/workflows/pdf-summary.lock.yml | 2 +- .github/workflows/plan.lock.yml | 2 +- .github/workflows/poem-bot.lock.yml | 2 +- .../workflows/pr-nitpick-reviewer.lock.yml | 2 +- .../prompt-clustering-analysis.lock.yml | 2 +- .github/workflows/python-data-charts.lock.yml | 2 +- .github/workflows/q.lock.yml | 2 +- .github/workflows/release.lock.yml | 8 +- .github/workflows/repo-tree-map.lock.yml | 2 +- .../repository-quality-improver.lock.yml | 2 +- .github/workflows/research.lock.yml | 2 +- .github/workflows/safe-output-health.lock.yml | 2 +- .../schema-consistency-checker.lock.yml | 2 +- .github/workflows/scout.lock.yml | 2 +- .github/workflows/security-fix-pr.lock.yml | 2 +- .../semantic-function-refactor.lock.yml | 2 +- .github/workflows/smoke-claude.lock.yml | 2 +- .github/workflows/smoke-codex.lock.yml | 2 +- .../smoke-copilot-no-firewall.lock.yml | 2 +- .../smoke-copilot-playwright.lock.yml | 4 +- .../smoke-copilot-safe-inputs.lock.yml | 4 +- .github/workflows/smoke-copilot.lock.yml | 2 +- .github/workflows/smoke-detector.lock.yml | 2 +- .github/workflows/smoke-srt.lock.yml | 2 +- .github/workflows/spec-kit-executor.lock.yml | 2 +- .github/workflows/speckit-dispatcher.lock.yml | 2 +- .../workflows/stale-repo-identifier.lock.yml | 2 +- .../workflows/static-analysis-report.lock.yml | 2 +- .github/workflows/super-linter.lock.yml | 2 +- .../workflows/technical-doc-writer.lock.yml | 2 +- .../test-discussion-expires.lock.yml | 2 +- .../workflows/test-python-safe-input.lock.yml | 4 +- .github/workflows/tidy.lock.yml | 2 +- .github/workflows/typist.lock.yml | 2 +- .github/workflows/unbloat-docs.lock.yml | 2 +- .github/workflows/video-analyzer.lock.yml | 2 +- .../workflows/weekly-issue-summary.lock.yml | 2 +- pkg/workflow/js/mcp_server_core.cjs | 2 +- 99 files changed, 196 insertions(+), 106 deletions(-) diff --git a/.github/workflows/ai-triage-campaign.lock.yml b/.github/workflows/ai-triage-campaign.lock.yml index ba8d64d9df..32ea2409a3 100644 --- a/.github/workflows/ai-triage-campaign.lock.yml +++ b/.github/workflows/ai-triage-campaign.lock.yml @@ -1053,7 +1053,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/archie.lock.yml b/.github/workflows/archie.lock.yml index e1a03df643..eec1303fe6 100644 --- a/.github/workflows/archie.lock.yml +++ b/.github/workflows/archie.lock.yml @@ -2540,7 +2540,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/artifacts-summary.lock.yml b/.github/workflows/artifacts-summary.lock.yml index 6b67621bf1..e3c8b085b0 100644 --- a/.github/workflows/artifacts-summary.lock.yml +++ b/.github/workflows/artifacts-summary.lock.yml @@ -1124,7 +1124,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/audit-workflows.lock.yml b/.github/workflows/audit-workflows.lock.yml index 93fdc21e07..f7fc807667 100644 --- a/.github/workflows/audit-workflows.lock.yml +++ b/.github/workflows/audit-workflows.lock.yml @@ -1941,7 +1941,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/blog-auditor.lock.yml b/.github/workflows/blog-auditor.lock.yml index a18c690335..2d0b7abc44 100644 --- a/.github/workflows/blog-auditor.lock.yml +++ b/.github/workflows/blog-auditor.lock.yml @@ -1439,7 +1439,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/brave.lock.yml b/.github/workflows/brave.lock.yml index 2523a7c889..25fd4c9467 100644 --- a/.github/workflows/brave.lock.yml +++ b/.github/workflows/brave.lock.yml @@ -2425,7 +2425,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/breaking-change-checker.lock.yml b/.github/workflows/breaking-change-checker.lock.yml index cc2ead0aac..9f81bfb7a1 100644 --- a/.github/workflows/breaking-change-checker.lock.yml +++ b/.github/workflows/breaking-change-checker.lock.yml @@ -1171,7 +1171,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/changeset.lock.yml b/.github/workflows/changeset.lock.yml index 7d684ecd6b..88b99a88ed 100644 --- a/.github/workflows/changeset.lock.yml +++ b/.github/workflows/changeset.lock.yml @@ -2044,7 +2044,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/ci-doctor.lock.yml b/.github/workflows/ci-doctor.lock.yml index 55d9132e9d..f0a99b1f5c 100644 --- a/.github/workflows/ci-doctor.lock.yml +++ b/.github/workflows/ci-doctor.lock.yml @@ -1858,7 +1858,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/cli-consistency-checker.lock.yml b/.github/workflows/cli-consistency-checker.lock.yml index 06d9e90083..222eb33a32 100644 --- a/.github/workflows/cli-consistency-checker.lock.yml +++ b/.github/workflows/cli-consistency-checker.lock.yml @@ -1172,7 +1172,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/cli-version-checker.lock.yml b/.github/workflows/cli-version-checker.lock.yml index 44b1dbe846..c083e432a2 100644 --- a/.github/workflows/cli-version-checker.lock.yml +++ b/.github/workflows/cli-version-checker.lock.yml @@ -1445,7 +1445,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/cloclo.lock.yml b/.github/workflows/cloclo.lock.yml index 99de4ca255..7bca2845fe 100644 --- a/.github/workflows/cloclo.lock.yml +++ b/.github/workflows/cloclo.lock.yml @@ -2845,7 +2845,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/close-old-discussions.lock.yml b/.github/workflows/close-old-discussions.lock.yml index a56895164d..de9a19630c 100644 --- a/.github/workflows/close-old-discussions.lock.yml +++ b/.github/workflows/close-old-discussions.lock.yml @@ -1339,7 +1339,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/commit-changes-analyzer.lock.yml b/.github/workflows/commit-changes-analyzer.lock.yml index af5f2eb360..d403a9a1e7 100644 --- a/.github/workflows/commit-changes-analyzer.lock.yml +++ b/.github/workflows/commit-changes-analyzer.lock.yml @@ -1398,7 +1398,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/copilot-agent-analysis.lock.yml b/.github/workflows/copilot-agent-analysis.lock.yml index c0008a01d1..2a56e525ee 100644 --- a/.github/workflows/copilot-agent-analysis.lock.yml +++ b/.github/workflows/copilot-agent-analysis.lock.yml @@ -1753,7 +1753,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/copilot-pr-merged-report.lock.yml b/.github/workflows/copilot-pr-merged-report.lock.yml index 178b9e1d36..396f57071b 100644 --- a/.github/workflows/copilot-pr-merged-report.lock.yml +++ b/.github/workflows/copilot-pr-merged-report.lock.yml @@ -1302,7 +1302,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, @@ -2320,7 +2320,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/copilot-pr-nlp-analysis.lock.yml b/.github/workflows/copilot-pr-nlp-analysis.lock.yml index 8fce391757..0e01e8fc81 100644 --- a/.github/workflows/copilot-pr-nlp-analysis.lock.yml +++ b/.github/workflows/copilot-pr-nlp-analysis.lock.yml @@ -1968,7 +1968,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/copilot-pr-prompt-analysis.lock.yml b/.github/workflows/copilot-pr-prompt-analysis.lock.yml index 76b6bcc3be..79ac0a37e4 100644 --- a/.github/workflows/copilot-pr-prompt-analysis.lock.yml +++ b/.github/workflows/copilot-pr-prompt-analysis.lock.yml @@ -1468,7 +1468,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/copilot-session-insights.lock.yml b/.github/workflows/copilot-session-insights.lock.yml index 472092b661..8da52394aa 100644 --- a/.github/workflows/copilot-session-insights.lock.yml +++ b/.github/workflows/copilot-session-insights.lock.yml @@ -2483,7 +2483,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/craft.lock.yml b/.github/workflows/craft.lock.yml index 3879704a53..7459968c01 100644 --- a/.github/workflows/craft.lock.yml +++ b/.github/workflows/craft.lock.yml @@ -2635,7 +2635,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-assign-issue-to-user.lock.yml b/.github/workflows/daily-assign-issue-to-user.lock.yml index a77ebccbfc..6e66fd0edc 100644 --- a/.github/workflows/daily-assign-issue-to-user.lock.yml +++ b/.github/workflows/daily-assign-issue-to-user.lock.yml @@ -1616,7 +1616,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-code-metrics.lock.yml b/.github/workflows/daily-code-metrics.lock.yml index 506a5ecffc..74cef0b01f 100644 --- a/.github/workflows/daily-code-metrics.lock.yml +++ b/.github/workflows/daily-code-metrics.lock.yml @@ -1985,7 +1985,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-copilot-token-report.lock.yml b/.github/workflows/daily-copilot-token-report.lock.yml index 530a397d01..0beeeeaa3e 100644 --- a/.github/workflows/daily-copilot-token-report.lock.yml +++ b/.github/workflows/daily-copilot-token-report.lock.yml @@ -2036,7 +2036,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-doc-updater.lock.yml b/.github/workflows/daily-doc-updater.lock.yml index bc3d277f5a..74cf3cb4ba 100644 --- a/.github/workflows/daily-doc-updater.lock.yml +++ b/.github/workflows/daily-doc-updater.lock.yml @@ -1297,7 +1297,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-fact.lock.yml b/.github/workflows/daily-fact.lock.yml index f06db10759..c9f10c630e 100644 --- a/.github/workflows/daily-fact.lock.yml +++ b/.github/workflows/daily-fact.lock.yml @@ -1625,7 +1625,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-file-diet.lock.yml b/.github/workflows/daily-file-diet.lock.yml index 2f3d1dbb11..02e5e2e473 100644 --- a/.github/workflows/daily-file-diet.lock.yml +++ b/.github/workflows/daily-file-diet.lock.yml @@ -1322,7 +1322,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-firewall-report.lock.yml b/.github/workflows/daily-firewall-report.lock.yml index a18306397a..8c4867d313 100644 --- a/.github/workflows/daily-firewall-report.lock.yml +++ b/.github/workflows/daily-firewall-report.lock.yml @@ -1737,7 +1737,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-issues-report.lock.yml b/.github/workflows/daily-issues-report.lock.yml index 17886667cb..918786dd61 100644 --- a/.github/workflows/daily-issues-report.lock.yml +++ b/.github/workflows/daily-issues-report.lock.yml @@ -2130,7 +2130,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-malicious-code-scan.lock.yml b/.github/workflows/daily-malicious-code-scan.lock.yml index 1b3181ee39..bce20ae589 100644 --- a/.github/workflows/daily-malicious-code-scan.lock.yml +++ b/.github/workflows/daily-malicious-code-scan.lock.yml @@ -1302,7 +1302,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-multi-device-docs-tester.lock.yml b/.github/workflows/daily-multi-device-docs-tester.lock.yml index 4482a4f3f3..0d971916af 100644 --- a/.github/workflows/daily-multi-device-docs-tester.lock.yml +++ b/.github/workflows/daily-multi-device-docs-tester.lock.yml @@ -1254,7 +1254,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-news.lock.yml b/.github/workflows/daily-news.lock.yml index b19f911600..6ced91ff2e 100644 --- a/.github/workflows/daily-news.lock.yml +++ b/.github/workflows/daily-news.lock.yml @@ -2055,7 +2055,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-performance-summary.lock.yml b/.github/workflows/daily-performance-summary.lock.yml index 5d2e2613d3..d59e4d1b9e 100644 --- a/.github/workflows/daily-performance-summary.lock.yml +++ b/.github/workflows/daily-performance-summary.lock.yml @@ -1892,7 +1892,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, @@ -2910,7 +2910,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-repo-chronicle.lock.yml b/.github/workflows/daily-repo-chronicle.lock.yml index 5ded285b7d..069ba5c4bb 100644 --- a/.github/workflows/daily-repo-chronicle.lock.yml +++ b/.github/workflows/daily-repo-chronicle.lock.yml @@ -1740,7 +1740,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/daily-team-status.lock.yml b/.github/workflows/daily-team-status.lock.yml index 3b5fe54281..c954c1ac3b 100644 --- a/.github/workflows/daily-team-status.lock.yml +++ b/.github/workflows/daily-team-status.lock.yml @@ -1020,6 +1020,96 @@ jobs: function normalizeTool(name) { return name.replace(/-/g, "_").toLowerCase(); } + async function handleRequest(server, request, defaultHandler) { + const { id, method, params } = request; + try { + if (!("id" in request)) { + return null; + } + let result; + if (method === "initialize") { + const protocolVersion = params?.protocolVersion || "2024-11-05"; + result = { + protocolVersion, + serverInfo: server.serverInfo, + capabilities: { + tools: {}, + }, + }; + } else if (method === "ping") { + result = {}; + } else if (method === "tools/list") { + const list = []; + Object.values(server.tools).forEach(tool => { + const toolDef = { + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + }; + list.push(toolDef); + }); + result = { tools: list }; + } else if (method === "tools/call") { + const name = params?.name; + const args = params?.arguments ?? {}; + if (!name || typeof name !== "string") { + throw { + code: -32602, + message: "Invalid params: 'name' must be a string", + }; + } + const tool = server.tools[normalizeTool(name)]; + if (!tool) { + throw { + code: -32602, + message: `Tool '${name}' not found`, + }; + } + let handler = tool.handler; + if (!handler && defaultHandler) { + handler = defaultHandler(tool.name); + } + if (!handler) { + throw { + code: -32603, + message: `No handler for tool: ${name}`, + }; + } + const missing = validateRequiredFields(args, tool.inputSchema); + if (missing.length) { + throw { + code: -32602, + message: `Invalid arguments: missing or empty ${missing.map(m => `'${m}'`).join(", ")}`, + }; + } + const handlerResult = await Promise.resolve(handler(args)); + const content = handlerResult && handlerResult.content ? handlerResult.content : []; + result = { content, isError: false }; + } else if (/^notifications\//.test(method)) { + return null; + } else { + throw { + code: -32601, + message: `Method not found: ${method}`, + }; + } + return { + jsonrpc: "2.0", + id, + result, + }; + } catch (error) { + const err = error; + return { + jsonrpc: "2.0", + id, + error: { + code: err.code || -32603, + message: err.message || "Internal error", + }, + }; + } + } async function handleMessage(server, req, defaultHandler) { if (!req || typeof req !== "object") { server.debug(`Invalid message: not an object`); diff --git a/.github/workflows/daily-workflow-updater.lock.yml b/.github/workflows/daily-workflow-updater.lock.yml index a40fa96dde..a2d826fa72 100644 --- a/.github/workflows/daily-workflow-updater.lock.yml +++ b/.github/workflows/daily-workflow-updater.lock.yml @@ -1163,7 +1163,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/deep-report.lock.yml b/.github/workflows/deep-report.lock.yml index 1d05a2be95..3914ff29e4 100644 --- a/.github/workflows/deep-report.lock.yml +++ b/.github/workflows/deep-report.lock.yml @@ -1612,7 +1612,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/dependabot-go-checker.lock.yml b/.github/workflows/dependabot-go-checker.lock.yml index c478aca044..18011b3566 100644 --- a/.github/workflows/dependabot-go-checker.lock.yml +++ b/.github/workflows/dependabot-go-checker.lock.yml @@ -1475,7 +1475,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/dev-hawk.lock.yml b/.github/workflows/dev-hawk.lock.yml index 8bb07fc420..869218239a 100644 --- a/.github/workflows/dev-hawk.lock.yml +++ b/.github/workflows/dev-hawk.lock.yml @@ -1689,7 +1689,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/dev.lock.yml b/.github/workflows/dev.lock.yml index 8df9cd8965..e8d7e2f524 100644 --- a/.github/workflows/dev.lock.yml +++ b/.github/workflows/dev.lock.yml @@ -815,7 +815,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/developer-docs-consolidator.lock.yml b/.github/workflows/developer-docs-consolidator.lock.yml index 21a3c17aff..d76ca5924b 100644 --- a/.github/workflows/developer-docs-consolidator.lock.yml +++ b/.github/workflows/developer-docs-consolidator.lock.yml @@ -1873,7 +1873,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/dictation-prompt.lock.yml b/.github/workflows/dictation-prompt.lock.yml index 5c946d49ee..64a46425f3 100644 --- a/.github/workflows/dictation-prompt.lock.yml +++ b/.github/workflows/dictation-prompt.lock.yml @@ -1149,7 +1149,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/docs-noob-tester.lock.yml b/.github/workflows/docs-noob-tester.lock.yml index ffe85fd2dc..76ed9cf778 100644 --- a/.github/workflows/docs-noob-tester.lock.yml +++ b/.github/workflows/docs-noob-tester.lock.yml @@ -1179,7 +1179,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/duplicate-code-detector.lock.yml b/.github/workflows/duplicate-code-detector.lock.yml index 409b7f37fc..0879c8ef8b 100644 --- a/.github/workflows/duplicate-code-detector.lock.yml +++ b/.github/workflows/duplicate-code-detector.lock.yml @@ -1227,7 +1227,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/example-workflow-analyzer.lock.yml b/.github/workflows/example-workflow-analyzer.lock.yml index ef81ac49a6..26c7b0e310 100644 --- a/.github/workflows/example-workflow-analyzer.lock.yml +++ b/.github/workflows/example-workflow-analyzer.lock.yml @@ -1196,7 +1196,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/github-mcp-structural-analysis.lock.yml b/.github/workflows/github-mcp-structural-analysis.lock.yml index df0781bb8c..f7445078e9 100644 --- a/.github/workflows/github-mcp-structural-analysis.lock.yml +++ b/.github/workflows/github-mcp-structural-analysis.lock.yml @@ -1840,7 +1840,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/github-mcp-tools-report.lock.yml b/.github/workflows/github-mcp-tools-report.lock.yml index f0da6f97e9..49984304eb 100644 --- a/.github/workflows/github-mcp-tools-report.lock.yml +++ b/.github/workflows/github-mcp-tools-report.lock.yml @@ -1724,7 +1724,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/glossary-maintainer.lock.yml b/.github/workflows/glossary-maintainer.lock.yml index c9fafd6690..ffde7e50d2 100644 --- a/.github/workflows/glossary-maintainer.lock.yml +++ b/.github/workflows/glossary-maintainer.lock.yml @@ -1663,7 +1663,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/go-fan.lock.yml b/.github/workflows/go-fan.lock.yml index f3c3b73d5d..f058acc2b5 100644 --- a/.github/workflows/go-fan.lock.yml +++ b/.github/workflows/go-fan.lock.yml @@ -1499,7 +1499,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/go-logger.lock.yml b/.github/workflows/go-logger.lock.yml index da083c2fe6..03565b0742 100644 --- a/.github/workflows/go-logger.lock.yml +++ b/.github/workflows/go-logger.lock.yml @@ -1425,7 +1425,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/go-pattern-detector.lock.yml b/.github/workflows/go-pattern-detector.lock.yml index 509d9fae13..be20e2bea0 100644 --- a/.github/workflows/go-pattern-detector.lock.yml +++ b/.github/workflows/go-pattern-detector.lock.yml @@ -1284,7 +1284,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/grumpy-reviewer.lock.yml b/.github/workflows/grumpy-reviewer.lock.yml index 798bee4160..6fa871fca9 100644 --- a/.github/workflows/grumpy-reviewer.lock.yml +++ b/.github/workflows/grumpy-reviewer.lock.yml @@ -2557,7 +2557,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/instructions-janitor.lock.yml b/.github/workflows/instructions-janitor.lock.yml index 108dcced98..ef76a15d22 100644 --- a/.github/workflows/instructions-janitor.lock.yml +++ b/.github/workflows/instructions-janitor.lock.yml @@ -1294,7 +1294,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/issue-arborist.lock.yml b/.github/workflows/issue-arborist.lock.yml index 79933f384f..2187c028e3 100644 --- a/.github/workflows/issue-arborist.lock.yml +++ b/.github/workflows/issue-arborist.lock.yml @@ -1273,7 +1273,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/issue-classifier.lock.yml b/.github/workflows/issue-classifier.lock.yml index 6836fd3c82..cf88d420dc 100644 --- a/.github/workflows/issue-classifier.lock.yml +++ b/.github/workflows/issue-classifier.lock.yml @@ -2282,7 +2282,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/issue-monster.lock.yml b/.github/workflows/issue-monster.lock.yml index df5eba835c..816a71f204 100644 --- a/.github/workflows/issue-monster.lock.yml +++ b/.github/workflows/issue-monster.lock.yml @@ -1833,7 +1833,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/issue-triage-agent.lock.yml b/.github/workflows/issue-triage-agent.lock.yml index 544c44bc97..98b9bf7236 100644 --- a/.github/workflows/issue-triage-agent.lock.yml +++ b/.github/workflows/issue-triage-agent.lock.yml @@ -1470,7 +1470,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/lockfile-stats.lock.yml b/.github/workflows/lockfile-stats.lock.yml index 70077cde25..c8debad6cf 100644 --- a/.github/workflows/lockfile-stats.lock.yml +++ b/.github/workflows/lockfile-stats.lock.yml @@ -1519,7 +1519,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/mcp-inspector.lock.yml b/.github/workflows/mcp-inspector.lock.yml index b9545141ad..b680ff2140 100644 --- a/.github/workflows/mcp-inspector.lock.yml +++ b/.github/workflows/mcp-inspector.lock.yml @@ -1359,7 +1359,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/mergefest.lock.yml b/.github/workflows/mergefest.lock.yml index 3289871887..b3c100403d 100644 --- a/.github/workflows/mergefest.lock.yml +++ b/.github/workflows/mergefest.lock.yml @@ -1702,7 +1702,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/notion-issue-summary.lock.yml b/.github/workflows/notion-issue-summary.lock.yml index f0717024d3..f6d0e83b19 100644 --- a/.github/workflows/notion-issue-summary.lock.yml +++ b/.github/workflows/notion-issue-summary.lock.yml @@ -938,7 +938,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/org-health-report.lock.yml b/.github/workflows/org-health-report.lock.yml index b44cbe099e..0ace008b06 100644 --- a/.github/workflows/org-health-report.lock.yml +++ b/.github/workflows/org-health-report.lock.yml @@ -1948,7 +1948,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/pdf-summary.lock.yml b/.github/workflows/pdf-summary.lock.yml index e2246b9919..d8354d479d 100644 --- a/.github/workflows/pdf-summary.lock.yml +++ b/.github/workflows/pdf-summary.lock.yml @@ -2542,7 +2542,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/plan.lock.yml b/.github/workflows/plan.lock.yml index 4b6b1a48b3..b9e7ba724f 100644 --- a/.github/workflows/plan.lock.yml +++ b/.github/workflows/plan.lock.yml @@ -1944,7 +1944,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/poem-bot.lock.yml b/.github/workflows/poem-bot.lock.yml index 9a31c148f4..586452f5a2 100644 --- a/.github/workflows/poem-bot.lock.yml +++ b/.github/workflows/poem-bot.lock.yml @@ -3672,7 +3672,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/pr-nitpick-reviewer.lock.yml b/.github/workflows/pr-nitpick-reviewer.lock.yml index 1630723368..b1ffde16b9 100644 --- a/.github/workflows/pr-nitpick-reviewer.lock.yml +++ b/.github/workflows/pr-nitpick-reviewer.lock.yml @@ -2593,7 +2593,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/prompt-clustering-analysis.lock.yml b/.github/workflows/prompt-clustering-analysis.lock.yml index 1c9a54f503..eb88c0550f 100644 --- a/.github/workflows/prompt-clustering-analysis.lock.yml +++ b/.github/workflows/prompt-clustering-analysis.lock.yml @@ -2205,7 +2205,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/python-data-charts.lock.yml b/.github/workflows/python-data-charts.lock.yml index 486a1fcb20..76097c892c 100644 --- a/.github/workflows/python-data-charts.lock.yml +++ b/.github/workflows/python-data-charts.lock.yml @@ -2041,7 +2041,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/q.lock.yml b/.github/workflows/q.lock.yml index 3a4a3de366..8444f28d09 100644 --- a/.github/workflows/q.lock.yml +++ b/.github/workflows/q.lock.yml @@ -2860,7 +2860,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/release.lock.yml b/.github/workflows/release.lock.yml index 30726a4b9b..f0b6c3cd00 100644 --- a/.github/workflows/release.lock.yml +++ b/.github/workflows/release.lock.yml @@ -1291,7 +1291,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, @@ -6209,19 +6209,19 @@ jobs: - name: Download Go modules run: go mod download - name: Generate SBOM (SPDX format) - uses: anchore/sbom-action@fbfd9c6c189226748411491745178e0c2017392d # v0 + uses: anchore/sbom-action@fbfd9c6c189226748411491745178e0c2017392d # v0.20.10 with: artifact-name: sbom.spdx.json format: spdx-json output-file: sbom.spdx.json - name: Generate SBOM (CycloneDX format) - uses: anchore/sbom-action@fbfd9c6c189226748411491745178e0c2017392d # v0 + uses: anchore/sbom-action@fbfd9c6c189226748411491745178e0c2017392d # v0.20.10 with: artifact-name: sbom.cdx.json format: cyclonedx-json output-file: sbom.cdx.json - name: Upload SBOM artifacts - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5 with: name: sbom-artifacts path: | diff --git a/.github/workflows/repo-tree-map.lock.yml b/.github/workflows/repo-tree-map.lock.yml index fb66284500..8f26a262c4 100644 --- a/.github/workflows/repo-tree-map.lock.yml +++ b/.github/workflows/repo-tree-map.lock.yml @@ -1177,7 +1177,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/repository-quality-improver.lock.yml b/.github/workflows/repository-quality-improver.lock.yml index 8d5168f99f..5cbbe9d974 100644 --- a/.github/workflows/repository-quality-improver.lock.yml +++ b/.github/workflows/repository-quality-improver.lock.yml @@ -1638,7 +1638,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/research.lock.yml b/.github/workflows/research.lock.yml index 6cba01d63f..75e35b55e2 100644 --- a/.github/workflows/research.lock.yml +++ b/.github/workflows/research.lock.yml @@ -1099,7 +1099,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/safe-output-health.lock.yml b/.github/workflows/safe-output-health.lock.yml index b7e9185399..a4bc56a9c6 100644 --- a/.github/workflows/safe-output-health.lock.yml +++ b/.github/workflows/safe-output-health.lock.yml @@ -1644,7 +1644,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/schema-consistency-checker.lock.yml b/.github/workflows/schema-consistency-checker.lock.yml index bc2524a6d4..5f5f8ff2aa 100644 --- a/.github/workflows/schema-consistency-checker.lock.yml +++ b/.github/workflows/schema-consistency-checker.lock.yml @@ -1529,7 +1529,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/scout.lock.yml b/.github/workflows/scout.lock.yml index fe82319004..6c93d3b352 100644 --- a/.github/workflows/scout.lock.yml +++ b/.github/workflows/scout.lock.yml @@ -2846,7 +2846,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/security-fix-pr.lock.yml b/.github/workflows/security-fix-pr.lock.yml index 472ee4f655..2625a45edd 100644 --- a/.github/workflows/security-fix-pr.lock.yml +++ b/.github/workflows/security-fix-pr.lock.yml @@ -1271,7 +1271,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/semantic-function-refactor.lock.yml b/.github/workflows/semantic-function-refactor.lock.yml index 550f869db5..a18145fbe9 100644 --- a/.github/workflows/semantic-function-refactor.lock.yml +++ b/.github/workflows/semantic-function-refactor.lock.yml @@ -1673,7 +1673,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-claude.lock.yml b/.github/workflows/smoke-claude.lock.yml index b9be9c1bee..309db46b28 100644 --- a/.github/workflows/smoke-claude.lock.yml +++ b/.github/workflows/smoke-claude.lock.yml @@ -2957,7 +2957,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-codex.lock.yml b/.github/workflows/smoke-codex.lock.yml index e7e8d02d2e..fec5e11c13 100644 --- a/.github/workflows/smoke-codex.lock.yml +++ b/.github/workflows/smoke-codex.lock.yml @@ -2727,7 +2727,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-copilot-no-firewall.lock.yml b/.github/workflows/smoke-copilot-no-firewall.lock.yml index 9114dcbae2..fae72ff036 100644 --- a/.github/workflows/smoke-copilot-no-firewall.lock.yml +++ b/.github/workflows/smoke-copilot-no-firewall.lock.yml @@ -2800,7 +2800,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-copilot-playwright.lock.yml b/.github/workflows/smoke-copilot-playwright.lock.yml index 101c117747..56433881b0 100644 --- a/.github/workflows/smoke-copilot-playwright.lock.yml +++ b/.github/workflows/smoke-copilot-playwright.lock.yml @@ -2805,7 +2805,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, @@ -3823,7 +3823,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-copilot-safe-inputs.lock.yml b/.github/workflows/smoke-copilot-safe-inputs.lock.yml index fb29881cd1..338dd4674f 100644 --- a/.github/workflows/smoke-copilot-safe-inputs.lock.yml +++ b/.github/workflows/smoke-copilot-safe-inputs.lock.yml @@ -2705,7 +2705,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, @@ -3723,7 +3723,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-copilot.lock.yml b/.github/workflows/smoke-copilot.lock.yml index 39c31ab0af..7edd54c011 100644 --- a/.github/workflows/smoke-copilot.lock.yml +++ b/.github/workflows/smoke-copilot.lock.yml @@ -2714,7 +2714,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-detector.lock.yml b/.github/workflows/smoke-detector.lock.yml index 0da6f73ce3..ceaaf59a24 100644 --- a/.github/workflows/smoke-detector.lock.yml +++ b/.github/workflows/smoke-detector.lock.yml @@ -2566,7 +2566,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/smoke-srt.lock.yml b/.github/workflows/smoke-srt.lock.yml index 4a896071ee..68cc65a608 100644 --- a/.github/workflows/smoke-srt.lock.yml +++ b/.github/workflows/smoke-srt.lock.yml @@ -969,7 +969,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/spec-kit-executor.lock.yml b/.github/workflows/spec-kit-executor.lock.yml index 44b3c581a1..2adbcc5214 100644 --- a/.github/workflows/spec-kit-executor.lock.yml +++ b/.github/workflows/spec-kit-executor.lock.yml @@ -1291,7 +1291,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/speckit-dispatcher.lock.yml b/.github/workflows/speckit-dispatcher.lock.yml index b647213dde..6032108cb4 100644 --- a/.github/workflows/speckit-dispatcher.lock.yml +++ b/.github/workflows/speckit-dispatcher.lock.yml @@ -2852,7 +2852,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/stale-repo-identifier.lock.yml b/.github/workflows/stale-repo-identifier.lock.yml index cfe10bcbd1..62fc176073 100644 --- a/.github/workflows/stale-repo-identifier.lock.yml +++ b/.github/workflows/stale-repo-identifier.lock.yml @@ -2038,7 +2038,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/static-analysis-report.lock.yml b/.github/workflows/static-analysis-report.lock.yml index 610da52420..e90ea11700 100644 --- a/.github/workflows/static-analysis-report.lock.yml +++ b/.github/workflows/static-analysis-report.lock.yml @@ -1553,7 +1553,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/super-linter.lock.yml b/.github/workflows/super-linter.lock.yml index 6297c83e1c..55661d972e 100644 --- a/.github/workflows/super-linter.lock.yml +++ b/.github/workflows/super-linter.lock.yml @@ -1293,7 +1293,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/technical-doc-writer.lock.yml b/.github/workflows/technical-doc-writer.lock.yml index d6b9efcd2c..e2d2e2167a 100644 --- a/.github/workflows/technical-doc-writer.lock.yml +++ b/.github/workflows/technical-doc-writer.lock.yml @@ -2151,7 +2151,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/test-discussion-expires.lock.yml b/.github/workflows/test-discussion-expires.lock.yml index fdca5b2e57..ea13025d8d 100644 --- a/.github/workflows/test-discussion-expires.lock.yml +++ b/.github/workflows/test-discussion-expires.lock.yml @@ -970,7 +970,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/test-python-safe-input.lock.yml b/.github/workflows/test-python-safe-input.lock.yml index ecd0fd6b8a..0d918d384d 100644 --- a/.github/workflows/test-python-safe-input.lock.yml +++ b/.github/workflows/test-python-safe-input.lock.yml @@ -1074,7 +1074,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, @@ -2092,7 +2092,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/tidy.lock.yml b/.github/workflows/tidy.lock.yml index 9b74c2dc50..e6c750b967 100644 --- a/.github/workflows/tidy.lock.yml +++ b/.github/workflows/tidy.lock.yml @@ -1581,7 +1581,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/typist.lock.yml b/.github/workflows/typist.lock.yml index 1464e08ea6..83f0b8a8fe 100644 --- a/.github/workflows/typist.lock.yml +++ b/.github/workflows/typist.lock.yml @@ -1658,7 +1658,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/unbloat-docs.lock.yml b/.github/workflows/unbloat-docs.lock.yml index c9f45dfd5c..df2269f024 100644 --- a/.github/workflows/unbloat-docs.lock.yml +++ b/.github/workflows/unbloat-docs.lock.yml @@ -2608,7 +2608,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/video-analyzer.lock.yml b/.github/workflows/video-analyzer.lock.yml index fc971e6876..6ca6918214 100644 --- a/.github/workflows/video-analyzer.lock.yml +++ b/.github/workflows/video-analyzer.lock.yml @@ -1285,7 +1285,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/.github/workflows/weekly-issue-summary.lock.yml b/.github/workflows/weekly-issue-summary.lock.yml index 92a9aa5aec..62d8c9e4d7 100644 --- a/.github/workflows/weekly-issue-summary.lock.yml +++ b/.github/workflows/weekly-issue-summary.lock.yml @@ -1642,7 +1642,7 @@ jobs: result, }; } catch (error) { - const err = error; + const err = (error); return { jsonrpc: "2.0", id, diff --git a/pkg/workflow/js/mcp_server_core.cjs b/pkg/workflow/js/mcp_server_core.cjs index 824e8bbd6e..8e8ddc22bf 100644 --- a/pkg/workflow/js/mcp_server_core.cjs +++ b/pkg/workflow/js/mcp_server_core.cjs @@ -579,7 +579,7 @@ async function handleRequest(server, request, defaultHandler) { result, }; } catch (error) { - const err = /** @type {any} */ error; + const err = /** @type {any} */ (error); return { jsonrpc: "2.0", id, From 611ccf63105bc42493d4bfe064f5efcbfb7c6ae3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 7 Dec 2025 23:02:17 +0000 Subject: [PATCH 6/6] Add changeset for consolidated MCP server refactor [skip-ci] --- .changeset/patch-consolidate-mcp-server.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .changeset/patch-consolidate-mcp-server.md diff --git a/.changeset/patch-consolidate-mcp-server.md b/.changeset/patch-consolidate-mcp-server.md new file mode 100644 index 0000000000..12559a7af2 --- /dev/null +++ b/.changeset/patch-consolidate-mcp-server.md @@ -0,0 +1,10 @@ +--- +"gh-aw": patch +--- + +Consolidate duplicate MCP server implementations by using a single shared core +implementation and removing the duplicate `mcp_server.cjs` code. + +This is an internal refactor that reduces duplicated code and simplifies +maintenance for MCP server transports (HTTP and stdio). +