MCPGateway

View as MarkdownOpen in Claude

MCPGateway is the main service class for the MCP-SWAIG gateway. It loads configuration from a JSON file, initializes an MCPManager and SessionManager, sets up authenticated HTTP routes, and runs a Flask server that translates between MCP tool calls and SignalWire SWAIG requests.

The gateway supports Basic auth and Bearer token authentication, rate limiting, SSL/TLS, and automatic session cleanup.

Properties

app
Flask

The underlying Flask application instance.

config
dict[str, Any]

The loaded and environment-variable-substituted configuration dictionary.

mcp_manager
MCPManager

The MCPManager instance that manages MCP service definitions and client lifecycles.

session_manager
SessionManager

The SessionManager instance that tracks active MCP sessions.

security
SecurityConfig

The SecurityConfig instance for authentication and security headers.

HTTP Endpoints

The gateway exposes the following REST endpoints. All endpoints except /health require authentication.

EndpointMethodDescription
/healthGETHealth check (no auth required)
/servicesGETList available MCP services
/services/<name>/toolsGETGet tools for a specific service
/services/<name>/callPOSTCall a tool on a service
/sessionsGETList active sessions
/sessions/<id>DELETEClose a specific session

main Function

1from signalwire.mcp_gateway import main

main() -> None

CLI entry point that parses command-line arguments and starts the gateway. Accepts a -c / --config flag to specify the configuration file path (defaults to config.json).

Use the mcp-gateway CLI command to run the gateway from the command line without writing any Python code.

Methods