From stdio to HTTP SSE: Hosting MCP Server with APISIX

Introduction

In modern API infrastructure, the HTTP protocol and streaming communication (such as SSE and WebSocket) have become mainstream methods for building real-time, interactive applications. In recent months, the Model Context Protocol (MCP) has gained popularity; however, most MCP Servers are implemented via stdio for local environments, making them inaccessible to external services and developers.

To bridge these services with modern API architectures, Apache APISIX has recently launched the <span>mcp-bridge</span> plugin, which helps you seamlessly convert stdio-based MCP Servers into HTTP SSE streaming interfaces, managed, routed, and traffic-controlled through an API gateway.

Introduction to the Model Context Protocol (MCP)

MCP is an open protocol designed to standardize how AI applications provide contextual 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. MCP supports a client-server architecture, where the MCP Server exposes specific functionalities that clients can access to retrieve the required data sources.

<span>mcp-bridge</span> Plugin Overview

The Apache APISIX <span>mcp-bridge</span> plugin hosts the MCP Server by launching a subprocess, taking over its stdio channel, converting client HTTP SSE requests into MCP protocol calls, and then pushing responses back to the client via SSE.

Core Features:

  • 📡 Wrap MCP RPC calls into SSE message streams
  • 🔄 Manage subprocess stdio lifecycle with queued RPC scheduling
  • đŸ—‚ī¸ Lightweight MCP session management (including session ID, ping keep-alive, and queue)
  • 🧰 Support session sharing among multiple workers, ensuring stability in APISIX multi-worker environments

Working Mechanism and Architecture Diagram

The following is a sequence diagram of the <span>mcp-bridge</span> plugin’s working mechanism, helping to understand the data flow from stdio to SSE:

From stdio to HTTP SSE: Hosting MCP Server with APISIX

✅ Highlights:

  • APISIX manages SSE long connections
  • <span>mcp-bridge</span> plugin manages subprocess + stdio + scheduling queue
  • Clients receive subprocess output in real-time, forming a streaming SSE response

Application Scenarios and Advantages

✅ Typical Application Scenarios

  • đŸ› ī¸ Integrating legacy MCP / stdio services into web platforms
  • đŸ–Ĩī¸ Hosting subprocess services across languages and platforms

✅ Advantages

  • 🌐 Modernization: stdio services instantly transform into HTTP SSE APIs
  • đŸ•šī¸ Managed: subprocess startup and IO lifecycle are uniformly managed
  • 📈 Scalability: session sharing in multi-worker environments supports large-scale deployments
  • 🔄 Flow control integration: seamlessly integrates with APISIX traffic control, authentication, and rate-limiting plugins into the API management system

Using Apache APISIX Authentication and Rate Limiting Plugins

Apache APISIX provides powerful authentication plugins (such as OAuth 2.0, JWT, and OIDC) and rate limiting plugins (such as rate limiting and circuit breaker mechanisms) that can further enhance the functionality of the <span>mcp-bridge</span> plugin. By using these plugins, you can ensure that the integrated MCP services receive secure authentication and traffic control, ensuring system reliability and stability.

Authentication Plugins

  • Support for OAuth 2.0, JWT, and OIDC plugins to help protect APIs and MCP services.
  • Automatically validate client identity when requests pass through the API gateway, preventing unauthorized access.

Rate Limiting Plugins

  • Rate limiting: restricts the request rate for each client to avoid system overload.
  • Circuit breaker: automatically switches or returns errors to prevent system crashes during high traffic or system failures.

Adding Authentication and Rate Limiting to MCP Server

From stdio to HTTP SSE: Hosting MCP Server with APISIX

By combining authentication and rate limiting plugins with the <span>mcp-bridge</span> plugin, you can enhance API security and ensure system stability in high-concurrency environments.

Roadmap

The current version is still a prototype, and the following features will be added in the future:

  • Currently, MCP sessions are not shared between multiple APISIX instances. If your APISIX cluster consists of multiple nodes, you must correctly configure session stickiness on the front-end LB to ensure that requests from the same client are always forwarded to the same APISIX instance for it to function properly.

  • The current MCP SSE connection is loop-driven. Although the loop does not consume too many resources (reading and writing stdio will be synchronous non-blocking calls), it is inefficient. We need to connect to some message queues to make it event-driven and scalable in a clustered manner.

  • The MCP session management module is just a prototype; we should also abstract another MCP proxy server module to support launching MCP Servers within APISIX for advanced scenarios. The proxy server module should be event-driven rather than loop-driven.

Conclusion

The Apache APISIX <span>mcp-bridge</span> plugin greatly simplifies the integration of Model Context Protocol (MCP) services with the HTTP API world, providing a modern streaming interface hosting method for traditional services.

From stdio to HTTP SSE: Hosting MCP Server with APISIXPrevious Reviews Recent Version Releases

Apache APISIX 3.12 | Apache APISIX 3.11 | Apache APISIX 3.10 | Apache APISIX 3.9 | Apache APISIX 3.8 | Apache APISIX 3.7 | Apache APISIX 3.6 | Apache APISIX 3.5 | Apache APISIX 3.4 | Apache APISIX 3.3 | Apache APISIX 3.2 | Apache APISIX Ingress 1.6 | Apache APISIX 3.1 | Apache APISIX 3.0 | Apache APISIX Ingress 1.5-rc1

Selected User Cases

Mobile Cloud | Tencent Games | Tencent Blue Whale | Tencent YouTu Lab | Airwallex | Sina Weibo | Beike | Zoom | Xueqiu | Tongcheng Shuke | Kingsoft Office | Upyun | Youzan | vivo | Horizon Robotics | Beeto | Xiaodian | Mafengwo | Junrun Human Resources | Xihua | Invesco Great Wall | Aerospace Giants | WeCity | Government Procurement Cloud | Migu Video | DataVisor

Ecological Cooperation

Elasticsearch | Doris | Kafka | TiDB | ClickHouse | NebulaGraph | OpenWhisk | Dubbo | Wasm | Dapr | Ory Hydra | Chaitin WAF | Coraza | DeepFlow

Recent Community Activities

2023 Apache APISIX Meetup Shanghai | 2023 Apache APISIX Meetup Malaysia | 2022 Apache APISIX Annual Memory | Apache APISIX × EDAS | Apache APISIX × Apache SeaTunnel | Apache APISIX × Apache EventMesh | Apache APISIX × Apache EventMesh | Apache APISIX × Apache Dubbo | 2022 Apache APISIX Meetup Nanjing | 2022 Hefei Cloud Native Technology Salon | Apache APISIX Summit 2022

About Apache APISIX

Apache APISIX is a dynamic, real-time, high-performance open-source API gateway that provides rich traffic management features such as load balancing, dynamic upstream, gray release, service circuit breaking, authentication, and observability.

As an API gateway, Apache APISIX helps enterprises quickly and securely handle API and microservice traffic, applicable in scenarios such as gateways, Kubernetes Ingress, and service meshes. It has been tested and highly recognized by professional cybersecurity organizations such as PwC’s data security team, Tencent Blue Army, Ping An Galaxy Lab, iQIYI SRC, and Yuanbao Technology Security Team. Apache APISIX Users (Partial)

From stdio to HTTP SSE: Hosting MCP Server with APISIX

  • Apache APISIX GitHub: https://github.com/apache/apisix

  • Apache APISIX Official Website: https://apisix.apache.org/

  • Apache APISIX Documentation: https://apisix.apache.org/zh/docs/apisix/getting-started

Leave a Comment