From stdio to HTTP SSE: Host Your MCP Server with APISIX API Gateway


Discover how the Apache APISIX mcp-bridge plugin seamlessly converts stdio-based MCP servers to scalable HTTP SSE services.
Introductionโ
In contemporary API infrastructure, HTTP protocols and streaming communications (like SSE, WebSocket) have become mainstream for building real-time, interactive applications. Over the past few months, the Model Context Protocol (MCP) has gained popularity. However, most MCP Servers are implemented via stdio for local environments and cannot be invoked by external services and developers.
To bridge these services with modern API architectures, Apache APISIX has introduced the mcp-bridge
plugin. It seamlessly converts stdio-based MCP services into HTTP SSE streaming interfaces and manages them through an API gateway for routing and traffic management.
Model Context Protocol (MCP) Overviewโ
MCP is an open protocol that standardizes how AI applications provide context information to large language models (LLMs). It allows developers to switch between different LLM providers while ensuring data security and facilitating integration with local or remote data sources. Supporting a client-server architecture, MCP servers expose specific functionalities that are accessible to clients via these servers.
What Is the mcp-bridge
Plugin?โ
The Apache APISIX mcp-bridge
plugin launches a subprocess to manage the MCP Server, takes over its stdio channel, transforms client HTTP SSE requests into MCP protocol calls, and pushes responses back to the client via SSE.
Key features:
๐ก Wraps MCP RPC calls into SSE message streams
๐ Manages subprocess stdio lifecycle with queued RPC scheduling
๏ฟฝ๏ฟฝ๏ธ Lightweight MCP session management (including session ID, ping keep-alive, and queuing)
๐งฐ Supports session sharing across multiple workers for stability in APISIX multi-worker environments
How It Works and Architecture Diagramโ
Below is a sequence diagram illustrating the working mechanism of the mcp-bridge
plugin, helping you to understand the data flow from stdio to SSE:
Click to Preview
โ Highlights:
APISIX manages SSE long-lived connections
The
mcp-bridge
plugin handles subprocesses, stdio, and scheduling queuesClients receive real-time subprocess outputs, forming streaming SSE responses
Application Scenarios and Benefitsโ
โ Typical Application Scenarios
๐ ๏ธ Integrating existing MCP/stdio services with web platforms
๐ฅ๏ธ Cross-language and cross-platform subprocess service management
โ Benefits
๐ Modernization: Instantly transform stdio services into HTTP SSE APIs
๐น๏ธ Managed: Unified management of subprocess launch and IO lifecycle
๐ Scalability: Session sharing in multi-worker environments for large-scale deployment support
๐ Traffic Control Integration: Seamless API management system integration with APISIX traffic control, authentication, and rate-limiting plugins
Authentication and Rate Limiting with Apache APISIX Pluginsโ
Apache APISIX provides robust authentication plugins (like OAuth 2.0, JWT, and OIDC) and rate-limiting plugins (such as rate limiting and circuit breakers). These enhance the mcp-bridge
plugin, ensuring secure authentication and traffic control for connected MCP services.
Authentication Pluginsโ
Support for OAuth 2.0, JWT, and OIDC plugins to protect APIs and MCP services.
Automatic client identity verification during API gateway requests to prevent unauthorized access.
Rate-Limiting Pluginsโ
Rate Limiting: Restricts each client's request rate to prevent system overload.
Circuit Breaker: Automatically switches or returns errors to avoid system crashes during high traffic or failures.
Adding Authentication and Rate Limiting to MCP Serversโ
Click to Preview
By integrating authentication and rate-limiting plugins with the mcp-bridge
plugin, you can enhance API security and ensure system stability in high-concurrency environments.
Roadmapโ
The current version is a prototype. Future enhancements include:
Currently, MCP sessions are not shared across multiple APISIX instances. For multi-node APISIX clusters, proper session persistence configuration on the front-end load balancer is essential to ensure requests from the same client always go to the same APISIX instance.
The current MCP SSE connection is loop-driven. While the loop doesn't consume many resources (stdio read/write will be synchronous non-blocking calls), it's not efficient. We plan to connect to a message queue for an event-driven, scalable cluster approach.
The MCP session management module is just a prototype. We intend to abstract an MCP proxy server module to support launching MCP servers within APISIX for advanced scenarios. This proxy server module will be event-driven rather than loop-driven.
Summaryโ
The Apache APISIX mcp-bridge
plugin significantly simplifies the integration of Model Context Protocol (MCP) services with the HTTP API world. It offers a modern streaming interface management approach for traditional services.
Subscribe to my newsletter
Read articles from Yilia Lin directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Yilia Lin
Yilia Lin
Technical Writer at API7.ai