From 45dce1006345086f58a52c4049d63fc6abb42411 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sat, 6 Dec 2025 17:18:18 +0000
Subject: [PATCH 1/9] Initial plan
From 3b23dfb43a120b4690fde18522acdd3eac01cbec Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sat, 6 Dec 2025 17:30:43 +0000
Subject: [PATCH 2/9] Implement local MCP HTTP transport layer without SDK
dependency
- Created mcp_http_transport.cjs with MCPServer and MCPHTTPTransport classes
- Updated safe_inputs_mcp_server_http.cjs to use local transport
- Removed @modelcontextprotocol/sdk from package.json
- All HTTP transport tests passing
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
---
pkg/workflow/js/mcp_http_transport.cjs | 366 ++++
pkg/workflow/js/package-lock.json | 1531 ++++-------------
pkg/workflow/js/package.json | 1 -
.../js/safe_inputs_mcp_server_http.cjs | 17 +-
4 files changed, 670 insertions(+), 1245 deletions(-)
create mode 100644 pkg/workflow/js/mcp_http_transport.cjs
diff --git a/pkg/workflow/js/mcp_http_transport.cjs b/pkg/workflow/js/mcp_http_transport.cjs
new file mode 100644
index 00000000000..6e1e1f03b22
--- /dev/null
+++ b/pkg/workflow/js/mcp_http_transport.cjs
@@ -0,0 +1,366 @@
+// @ts-check
+///
+
+/**
+ * Local MCP HTTP Transport Implementation
+ *
+ * This module provides a standalone implementation of the MCP (Model Context Protocol)
+ * HTTP transport layer, removing the dependency on @modelcontextprotocol/sdk.
+ *
+ * It implements:
+ * - JSON-RPC 2.0 protocol handling
+ * - HTTP request/response handling
+ * - Session management (stateful and stateless modes)
+ * - CORS support for development
+ *
+ * References:
+ * - MCP Specification: https://spec.modelcontextprotocol.io
+ * - JSON-RPC 2.0: https://www.jsonrpc.org/specification
+ */
+
+const http = require("http");
+const { randomUUID } = require("crypto");
+
+/**
+ * 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 {MCPHTTPTransport} transport - Transport instance
+ */
+ 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