Model Context Protocol (MCP) Server
Relevant source files
The following files were used as context for generating this wiki page:
The Model Context Protocol (MCP) Server provides a standardized interface that allows external Large Language Model (LLM) agents to discover and execute superglue tools. It acts as a bridge between the superglue platform and MCP-compatible clients like Cursor, Claude Desktop, and Langdock, enabling these agents to treat deterministic multi-step workflows as native callable functions.
Sources: packages/web/src/lib/agent/skills/content/superglue-concepts.md:92-97, packages/web/src/lib/agent/agent-prompts.ts:321-322
Architecture and Components
The MCP implementation utilizes the @modelcontextprotocol/sdk to establish a server that communicates via JSON-RPC 2.0. It leverages a streamable HTTP transport layer to handle client connections and session management.
Key Components
- McpServer Instance: Manages the server lifecycle, capabilities, and tool registrations.
- StreamableHTTPServerTransport: Handles the underlying communication protocol over HTTP, generating unique session IDs for every connection.
- SuperglueClient: Facilitates communication between the MCP server and the core superglue API to fetch tool definitions and trigger executions.
- Zod Schema Registry: Dynamically converts JSON Schema definitions from superglue tools into Zod schemas required for MCP registration.
Sources: packages/core/mcp/mcp-server.ts:130-155, packages/core/mcp/mcp-server.ts:335-350, packages/web/src/lib/external/anthropic-mcp/types.ts:14-16
Data Flow Diagram
The following diagram illustrates how an LLM agent interacts with superglue via the MCP Server.
This diagram shows the initialization and discovery flow where the server exposes platform tools to the client. Sources: packages/core/mcp/mcp-server.ts:153-176, packages/web/src/lib/agent/skills/content/superglue-concepts.md:99-106
Tool Registration and Schema Conversion
The server fetches all workflows accessible to the provided API key and registers them as native MCP tools. Because MCP requires Zod schemas for input validation while superglue uses JSON Schema, the server performs a recursive conversion.
Schema Mapping Logic
The conversion process handles the following data types:
- Strings: Includes support for enums and descriptions.
- Numbers: Maps both integers and floats to Zod numbers.
- Objects: Recursively builds nested object shapes and marks optional vs. required fields.
- Arrays: Converts item schemas for list support.
- Unions: Handles nullable types by detecting
["type", "null"]patterns.
Sources: packages/core/mcp/mcp-server.ts:35-104
Tool Name Sanitization
MCP tool names must be alphanumeric with underscores. The server sanitizes tool IDs and handles naming collisions by appending numeric suffixes.
| Step | Action | Result Example |
|---|---|---|
| 1 | Replace non-alphanumeric with _ | my-tool-id -> my_tool_id |
| 2 | Collapse multiple underscores | tool__name -> tool_name |
| 3 | Trim leading/trailing underscores | _tool_ -> tool |
| 4 | Resolve collisions | tool (exists) -> tool_1 |
Sources: packages/core/mcp/mcp-server.ts:111-128
Core Capabilities
The server registers specialized tools and metadata to enhance agent interactions and multi-tenancy support.
The authenticate Tool
The server always includes an authenticate tool. This tool generates an authentication portal link that end users use to connect their accounts if a tool execution fails due to missing credentials.
| Parameter | Type | Description |
|---|---|---|
systemId | string (optional) | Specific system ID to reauthenticate |
Sources: packages/core/mcp/mcp-server.ts:257-275
Result Truncation
To prevent LLM context overflow, tool execution results are processed by truncateToolExecutionResult before being sent back to the agent. This ensures that large data payloads do not break the communication session.
Sources: packages/core/mcp/mcp-server.ts:223-226, packages/core/mcp/mcp-server-utils.ts
Execution Pipeline
When an agent invokes a tool, the MCP server follows a deterministic execution path.
This diagram outlines the synchronous request-response flow for tool execution. Sources: packages/core/mcp/mcp-server.ts:200-245
Server Configuration
The MCP server is configured via environment variables and the initialization request.
| Variable | Default Value | Description |
|---|---|---|
API_PORT | 3002 | Port for the local superglue API |
API_ENDPOINT | http://localhost:${API_PORT} | Target URL for the superglue client |
SUPERGLUE_APP_URL | https://app.superglue.cloud | Base URL for the web dashboard |
Sources: packages/core/mcp/mcp-server.ts:145-146, packages/core/mcp/mcp-server.ts:271
Conclusion
The MCP Server extends superglue's reach by allowing LLM agents to interact with deterministic workflows. By automating the conversion of platform-specific tool definitions into the Model Context Protocol format, the server enables seamless integration into AI-driven environments while maintaining strict RBAC and security standards defined by the user's API key.
Sources: packages/web/src/lib/agent/skills/content/superglue-concepts.md:105-106, packages/core/mcp/mcp-server.ts:153-156