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 a73e0604740..160a26701ef 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 5a9b917a0f9..32ea2409a3e 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 cb684fffa95..eec1303fe6d 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 7b93a9617ee..e3c8b085b07 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 5b2a9c61b57..f7fc8076679 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 df3dd99e4f4..2d0b7abc44f 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 9109abe1ecf..25fd4c94677 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 192ae63e434..9f81bfb7a18 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 edaf972fed3..88b99a88ed6 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 bec6519b9b2..f0a99b1f5c3 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 70bec5537ac..222eb33a324 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 b21995706c9..c083e432a28 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 dcebc5254ce..7bca2845fe1 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 e8dc6a8df5b..de9a19630c5 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 7457c3bad8c..d403a9a1e7d 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 a9f5559a4b4..2a56e525ee9 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 017c046a3d9..396f57071be 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 ad248b00c49..0e01e8fc81a 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 08ba4114f9d..79ac0a37e4c 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 ffee03280a6..8da52394aab 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 2044a11a3b5..7459968c014 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 cbdcae7d54c..6e66fd0edcc 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 8504371814a..74cef0b01f9 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 4c5d9b14910..0beeeeaa3e4 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 cc2bd2b97fa..74cf3cb4ba4 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 de18c4ff4d3..c9f10c630e6 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 b9bab5653d5..02e5e2e473f 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 3df31de41bd..8c4867d313e 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 896b6c36ab8..918786dd611 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 225ba51a437..bce20ae589e 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 d2f678ba2b0..0d971916af5 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 815a9afb9d4..6ced91ff2ee 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 f6b7a8ce71a..d59e4d1b9e9 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 22b33130ed7..069ba5c4bbc 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 ca62972b5e5..a2d826fa726 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 2fc56da2b49..3914ff29e42 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 45b396a76df..18011b35668 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 a82b70b3fbf..869218239a9 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 32a106fa1e2..e8d7e2f5243 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 612ebee3e41..d76ca5924be 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 6262a4d13f8..64a46425f3d 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 e9d777da9c3..76ed9cf778c 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 7a77a989e64..0879c8ef8be 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 78ec3db1040..26c7b0e310f 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 0d7038df08a..f7445078e9c 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 5d7f50d5fb2..49984304eb4 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 e831baa1831..654b3d07624 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 54741caf6d1..f058acc2b5a 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 e5a99638823..03565b0742f 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 5176437b4a7..be20e2bea00 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 811f53d6431..6fa871fca91 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 4e997b7cb01..ef76a15d224 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 7f97004ee03..2187c028e35 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 fcc411f31c2..cf88d420dce 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 714d85261c4..816a71f2049 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 b239371f962..98b9bf72369 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 2bac64b37e0..c8debad6cf0 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 62402e87539..b680ff21402 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 8251f56419c..b3c100403dc 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 5be256c192b..f6d0e83b198 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 9a78fd7151d..0ace008b065 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 1680e79680a..d8354d479d4 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 d9ce6b05a05..b9e7ba724fa 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 a3247dc4f6e..586452f5a26 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 53e1b06b659..b1ffde16b9f 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 1446f514d40..eb88c0550f8 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 fecf9a968f4..76097c892ca 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 3d4a421b0cc..8444f28d090 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 160a26701ef..f0b6c3cd006 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 c98a78e24ce..8f26a262c4f 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 1fadf001b95..5cbbe9d9741 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 7c52d468a45..75e35b55e21 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 0a52ce98586..a4bc56a9c6c 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 a96b93316ad..5f5f8ff2aad 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 f684ee36ca0..6c93d3b352c 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 9e82e1ffed9..2625a45edd6 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 5c554c8a0b3..a18145fbe99 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 4aa66de93e8..309db46b284 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 0a099abfa1e..fec5e11c13e 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 8bf1c549d83..fae72ff0367 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 f26a3d18411..56433881b07 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 dec1c7ae63e..338dd4674f1 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 41557ae08c1..7edd54c0116 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 197f0a8ce15..ceaaf59a246 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 69953d63046..68cc65a608d 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 be91499c83d..2adbcc5214e 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 70b1651a56d..3c28ab8344d 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 10785842a73..62fc176073e 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 46b013bd82e..e90ea11700e 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 92c6604ae45..55661d972e7 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 0cf7d7c535b..8992ffe21eb 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 e782b964d0e..ea13025d8d6 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 dd13a92b0ab..0d918d384d1 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 0b08a6fa5ee..e6c750b9679 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 0876f1e719c..83f0b8a8fe3 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 1590b821686..df2269f024f 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 0db0bc467c0..6ca6918214b 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 540f1eeb0ae..62d8c9e4d7f 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 b579b0bd8dd..e46426c60a3 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 e64b5164a71..a291352a6a6 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 d5aeb92e040..b37a581e4da 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 a6762f214ac..00000000000 --- 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 f127a98752c..00000000000 --- 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 1b8a3c6d524..8e8ddc22bfe 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 58de9b0c665..d6b91c6ed7a 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 6f3c4334f33..3c9b264a755 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 32ea2409a3e..ba8d64d9dfb 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 eec1303fe6d..e1a03df643f 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 e3c8b085b07..6b67621bf1a 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 f7fc8076679..93fdc21e074 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 2d0b7abc44f..a18c6903354 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 25fd4c94677..2523a7c889a 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 9f81bfb7a18..cc2ead0aace 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 88b99a88ed6..7d684ecd6b2 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 f0a99b1f5c3..55d9132e9dc 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 222eb33a324..06d9e90083d 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 c083e432a28..44b1dbe8464 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 7bca2845fe1..99de4ca255c 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 de9a19630c5..a56895164db 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 d403a9a1e7d..af5f2eb3605 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 2a56e525ee9..c0008a01d16 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 396f57071be..178b9e1d36a 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 0e01e8fc81a..8fce3917578 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 79ac0a37e4c..76b6bcc3beb 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 8da52394aab..472092b661c 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 7459968c014..3879704a536 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 6e66fd0edcc..a77ebccbfc3 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 74cef0b01f9..506a5ecffc7 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 0beeeeaa3e4..530a397d010 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 74cf3cb4ba4..bc3d277f5a1 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 c9f10c630e6..f06db107592 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 02e5e2e473f..2f3d1dbb11e 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 8c4867d313e..a18306397a9 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 918786dd611..17886667cb0 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 bce20ae589e..1b3181ee39e 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 0d971916af5..4482a4f3f39 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 6ced91ff2ee..b19f911600c 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 d59e4d1b9e9..5d2e2613d30 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 069ba5c4bbc..5ded285b7d1 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 a2d826fa726..a40fa96dde7 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 3914ff29e42..1d05a2be957 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 18011b35668..c478aca044a 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 869218239a9..8bb07fc4205 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 e8d7e2f5243..8df9cd89658 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 d76ca5924be..21a3c17affb 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 64a46425f3d..5c946d49ee9 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 76ed9cf778c..ffe85fd2dc8 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 0879c8ef8be..409b7f37fc6 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 26c7b0e310f..ef81ac49a69 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 f7445078e9c..df0781bb8c0 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 49984304eb4..f0da6f97e9a 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 654b3d07624..e1bcbe530dc 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 f058acc2b5a..f3c3b73d5d1 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 03565b0742f..da083c2fe6b 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 be20e2bea00..509d9fae138 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 6fa871fca91..798bee41606 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 ef76a15d224..108dcced98d 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 2187c028e35..79933f384f8 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 cf88d420dce..6836fd3c82f 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 816a71f2049..df5eba835ca 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 98b9bf72369..544c44bc97a 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 c8debad6cf0..70077cde259 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 b680ff21402..b9545141ade 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 b3c100403dc..32898718876 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 f6d0e83b198..f0717024d39 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 0ace008b065..b44cbe099e0 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 d8354d479d4..e2246b99194 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 b9e7ba724fa..4b6b1a48b3f 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 586452f5a26..9a31c148f44 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 b1ffde16b9f..16307233684 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 eb88c0550f8..1c9a54f5032 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 76097c892ca..486a1fcb20e 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 8444f28d090..3a4a3de3664 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 f0b6c3cd006..1f2c1681dfc 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 8f26a262c4f..fb66284500f 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 5cbbe9d9741..8d5168f99fc 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 75e35b55e21..6cba01d63fc 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 a4bc56a9c6c..b7e9185399f 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 5f5f8ff2aad..bc2524a6d43 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 6c93d3b352c..fe82319004e 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 2625a45edd6..472ee4f6554 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 a18145fbe99..550f869db5a 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 309db46b284..b9be9c1bee7 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 fec5e11c13e..e7e8d02d2ed 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 fae72ff0367..9114dcbae2c 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 56433881b07..101c1177475 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 338dd4674f1..fb29881cd14 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 7edd54c0116..39c31ab0afd 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 ceaaf59a246..0da6f73ce33 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 68cc65a608d..4a896071eee 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 2adbcc5214e..44b3c581a10 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 3c28ab8344d..35964e66672 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 62fc176073e..cfe10bcbd17 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 e90ea11700e..610da52420f 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 55661d972e7..6297c83e1c7 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 8992ffe21eb..fdc9bfda16f 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 ea13025d8d6..fdca5b2e579 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 0d918d384d1..ecd0fd6b8a8 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 e6c750b9679..9b74c2dc508 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 83f0b8a8fe3..1464e08ea6d 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 df2269f024f..c9f45dfd5ce 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 6ca6918214b..fc971e68765 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 62d8c9e4d7f..92a9aa5aecf 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 8e8ddc22bfe..824e8bbd6eb 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 ba8d64d9dfb..32ea2409a3e 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 e1a03df643f..eec1303fe6d 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 6b67621bf1a..e3c8b085b07 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 93fdc21e074..f7fc8076679 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 a18c6903354..2d0b7abc44f 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 2523a7c889a..25fd4c94677 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 cc2ead0aace..9f81bfb7a18 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 7d684ecd6b2..88b99a88ed6 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 55d9132e9dc..f0a99b1f5c3 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 06d9e90083d..222eb33a324 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 44b1dbe8464..c083e432a28 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 99de4ca255c..7bca2845fe1 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 a56895164db..de9a19630c5 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 af5f2eb3605..d403a9a1e7d 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 c0008a01d16..2a56e525ee9 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 178b9e1d36a..396f57071be 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 8fce3917578..0e01e8fc81a 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 76b6bcc3beb..79ac0a37e4c 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 472092b661c..8da52394aab 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 3879704a536..7459968c014 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 a77ebccbfc3..6e66fd0edcc 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 506a5ecffc7..74cef0b01f9 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 530a397d010..0beeeeaa3e4 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 bc3d277f5a1..74cf3cb4ba4 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 f06db107592..c9f10c630e6 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 2f3d1dbb11e..02e5e2e473f 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 a18306397a9..8c4867d313e 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 17886667cb0..918786dd611 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 1b3181ee39e..bce20ae589e 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 4482a4f3f39..0d971916af5 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 b19f911600c..6ced91ff2ee 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 5d2e2613d30..d59e4d1b9e9 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 5ded285b7d1..069ba5c4bbc 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 3b5fe54281b..c954c1ac3bc 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 a40fa96dde7..a2d826fa726 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 1d05a2be957..3914ff29e42 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 c478aca044a..18011b35668 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 8bb07fc4205..869218239a9 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 8df9cd89658..e8d7e2f5243 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 21a3c17affb..d76ca5924be 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 5c946d49ee9..64a46425f3d 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 ffe85fd2dc8..76ed9cf778c 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 409b7f37fc6..0879c8ef8be 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 ef81ac49a69..26c7b0e310f 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 df0781bb8c0..f7445078e9c 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 f0da6f97e9a..49984304eb4 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 c9fafd6690e..ffde7e50d24 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 f3c3b73d5d1..f058acc2b5a 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 da083c2fe6b..03565b0742f 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 509d9fae138..be20e2bea00 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 798bee41606..6fa871fca91 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 108dcced98d..ef76a15d224 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 79933f384f8..2187c028e35 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 6836fd3c82f..cf88d420dce 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 df5eba835ca..816a71f2049 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 544c44bc97a..98b9bf72369 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 70077cde259..c8debad6cf0 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 b9545141ade..b680ff21402 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 32898718876..b3c100403dc 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 f0717024d39..f6d0e83b198 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 b44cbe099e0..0ace008b065 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 e2246b99194..d8354d479d4 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 4b6b1a48b3f..b9e7ba724fa 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 9a31c148f44..586452f5a26 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 16307233684..b1ffde16b9f 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 1c9a54f5032..eb88c0550f8 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 486a1fcb20e..76097c892ca 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 3a4a3de3664..8444f28d090 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 30726a4b9bc..f0b6c3cd006 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 fb66284500f..8f26a262c4f 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 8d5168f99fc..5cbbe9d9741 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 6cba01d63fc..75e35b55e21 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 b7e9185399f..a4bc56a9c6c 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 bc2524a6d43..5f5f8ff2aad 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 fe82319004e..6c93d3b352c 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 472ee4f6554..2625a45edd6 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 550f869db5a..a18145fbe99 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 b9be9c1bee7..309db46b284 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 e7e8d02d2ed..fec5e11c13e 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 9114dcbae2c..fae72ff0367 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 101c1177475..56433881b07 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 fb29881cd14..338dd4674f1 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 39c31ab0afd..7edd54c0116 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 0da6f73ce33..ceaaf59a246 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 4a896071eee..68cc65a608d 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 44b3c581a10..2adbcc5214e 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 b647213dded..6032108cb41 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 cfe10bcbd17..62fc176073e 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 610da52420f..e90ea11700e 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 6297c83e1c7..55661d972e7 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 d6b9efcd2ce..e2d2e2167a6 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 fdca5b2e579..ea13025d8d6 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 ecd0fd6b8a8..0d918d384d1 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 9b74c2dc508..e6c750b9679 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 1464e08ea6d..83f0b8a8fe3 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 c9f45dfd5ce..df2269f024f 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 fc971e68765..6ca6918214b 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 92a9aa5aecf..62d8c9e4d7f 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 824e8bbd6eb..8e8ddc22bfe 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 00000000000..12559a7af2c --- /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). +