Created
October 7, 2025 14:53
-
-
Save rlnorthcutt/3c33cd79783fe0c1f9e8f7569165c696 to your computer and use it in GitHub Desktop.
HAProxy Full config for MCP Streaming HTTP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # /etc/haproxy/haproxy.cfg | |
| global | |
| log stdout format raw local0 | |
| defaults | |
| mode http | |
| timeout client 50000 | |
| timeout server 50000 | |
| timeout connect 5000 | |
| frontend mcp_frontend | |
| bind :80 | |
| log global | |
| # --- Request Validation --- | |
| # Define ACLs to check for required Accept header values. | |
| acl accept_events req.hdr(accept) -m sub text/event-stream | |
| acl accept_json req.hdr(accept) -m sub application/json | |
| # Deny GET requests if they don't accept event-stream. | |
| http-request deny if METH_GET !accept_events | |
| # Deny POST requests if they don't accept both event-stream and json. | |
| http-request deny if METH_POST !accept_events or METH_POST !accept_json | |
| # Send valid requests to the backend servers. | |
| default_backend mcp_servers | |
| backend mcp_servers | |
| balance roundrobin | |
| # --- Session Persistence --- | |
| # Define a stick table to track sessions. | |
| # - type: string (for the session ID) | |
| # - len: 64 (max length of the ID) | |
| # - size: 1m (can store 1 million entries) | |
| # - expire: 1h (remove entries after 1 hour of inactivity) | |
| stick-table type string len 64 size 1m expire 1h | |
| # For subsequent requests, stick to a server if the client | |
| # sends the mcp-session-id header we already know. | |
| stick on hdr(mcp-session-id) | |
| # For the first response, learn and store the session ID | |
| # that the server sends back. | |
| stick store-response res.hdr(mcp-session-id) | |
| # --- Server Definitions --- | |
| # Add your MCP servers here. | |
| server mcp_server_1 10.0.1.10:8000 check | |
| server mcp_server_2 10.0.1.11:8000 check | |
| # server mcp_server_3 ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment