bzp2010 opened a new pull request, #12151: URL: https://github.com/apache/apisix/pull/12151
### Description This PR introduces a new plugin called mcp-bridge that allows users to convert any stdio-based mcp server to HTTP SSE-based. It consists of two parts, a plugin for handling stdio and managing subprocess lifecycles, and a submodule for supporting mcp session management. #### `mcp-bridge` plugin The `mcp-bridge` plugin will start an HTTP SSE response when a request arrives and create a queue to cache MCP RPC calls from the client. The plugin will also start a child process and prepare its stdio according to the configuration. After starting the SSE response and the child process is ready, it enters a loop and in each loop takes the cached RPC call out of the queue and puts it into the stdin of the child process, then reads the response from the stdout and the stderr, and if the response can't be read starts the next round of the loop, and the process of reading the response fails fast. #### MCP session management This PR also includes a lightweight MCP session management module that will assign session ids and manage queues and ping timers on sessions. It uses shared dict to ensure that it works properly when SSE connections and RPC calls are not handled by the same nginx worker. #### Additionally The plugin has implemented prototype functionality for managing MCP server protocol conversions and proxies, but still has some shortcomings. 1. Right now, the MCP session will not be shared between multiple APISIX instances, if your APISIX cluster consists of multiple nodes, you have to configure the session stickiness correctly on the front LB to ensure that requests from the same client will always be forwarded to the same APISIX instance, only then it will work properly 2. Current MCP SSE connections are loop-driven, and although loops don't take up too many resources (where reading and writing stdio would be synchronous non-blocking calls), this is not efficient, and we need to connect to some message queues to make them event-driven and scalable in a clustered fashion. 3. The MCP session management module is just a prototype, we should also abstract another MCP proxy server module to support starting an MCP server inside APISIX to support advanced scenarios. ### Checklist - [x] I have explained the need for this PR and the problem it solves - [x] I have explained the changes or the new features added to this PR - [x] I have added tests corresponding to this change - [x] I have updated the documentation to reflect this change - [x] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first) <!-- Note 1. Mark the PR as draft until it's ready to be reviewed. 2. Always add/update tests for any changes unless you have a good reason. 3. Always update the documentation to reflect the changes made in the PR. 4. Make a new commit to resolve conversations instead of `push -f`. 5. To resolve merge conflicts, merge master instead of rebasing. 6. Use "request review" to notify the reviewer after making changes. 7. Only a reviewer can mark a conversation as resolved. --> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org