MCP Gateway
MCP Gateway
The MCP Gateway bridges Model Context Protocol (MCP) servers with SignalWire AI agents, enabling your agents to use any MCP-compatible tool through a managed gateway service.
What is MCP?
The Model Context Protocol (MCP) is an open standard for connecting AI systems to external tools and data sources. MCP servers expose “tools” (functions) that AI models can call—similar to SWAIG functions but using a standardized protocol.
The MCP Gateway acts as a bridge: it runs MCP servers and exposes their tools as SWAIG functions that SignalWire agents can call. This lets you leverage the growing ecosystem of MCP tools without modifying your agent code.
Architecture Overview

When to Use MCP Gateway
Good use cases:
- Integrating existing MCP tools without modification
- Using community MCP servers (database connectors, APIs, etc.)
- Isolating tool execution in sandboxed processes
- Managing multiple tool services from one gateway
- Session-based tools that maintain state across calls
Consider alternatives when:
- You need simple, stateless functions (use SWAIG directly)
- You’re building custom tools from scratch (SWAIG is simpler)
- Low latency is critical (gateway adds network hop)
- You don’t need MCP ecosystem compatibility
Components
The MCP Gateway consists of:
Installation
The MCP Gateway is included in the SignalWire Agents SDK. Install with the gateway dependencies:
Once installed, the mcp-gateway CLI command is available:
Setting Up the Gateway
1. Configuration
Create a configuration file for the gateway:
Configuration supports environment variable substitution:
2. Start the Gateway
The gateway starts on the configured port (default 8080).
3. Connect Your Agent
Skill Configuration
The mcp_gateway skill accepts these parameters:
Service Configuration
Each service in the services array specifies:
Tools are exposed as SWAIG functions with names like mcp_{service}_{tool}.
Gateway API
The gateway exposes these REST endpoints:
Example API Calls
Session Management
Sessions are tied to SignalWire call IDs:
- First tool call: Gateway creates new MCP process and session
- Subsequent calls: Same session reused (process stays alive)
- Call ends: Hangup hook closes session and terminates process
This enables stateful tools—a todo list MCP can maintain items across multiple tool calls within the same phone call.
Security Features
Authentication
The gateway supports two authentication methods:
Sandbox Isolation
MCP processes run in sandboxed environments:
Sandbox levels:
Resource limits (when enabled):
- CPU: 300 seconds
- Memory: 512 MB
- Processes: 10
- File size: 10 MB
Rate Limiting
Configure rate limits per endpoint:
Writing MCP Servers
MCP servers communicate via JSON-RPC 2.0 over stdin/stdout. The gateway spawns these as child processes and communicates with them via stdin/stdout. Here’s a minimal example:
Testing
Test with swaig-test
Test Gateway Directly
Docker Deployment
The gateway includes Docker support: