feat: SSE MCP transport — shared state with proxy on :9090#14
Merged
Conversation
mcp.rs: refactored — extracted pure dispatch_tool_call() + pub tool_definitions()
for shared use by stdio and SSE transports. Stdio is always-available fallback.
mcp_sse.rs: new module (~170 lines)
- GET /mcp/sse — SSE connection with session ID + endpoint event
- POST /mcp/messages?sessionId=xxx — JSON-RPC dispatch, response via SSE
- tokio mpsc channel for async response delivery
- Auto-cleanup on SSE disconnect + 5-min idle TTL
- Inline UUID generation (zero external deps)
proxy.rs: wired SSE MCP routes into axum router alongside existing routes
- /mcp/sse (GET) and /mcp/messages (POST) coexist with daemon + proxy routes
init.rs: inject_sse_mcp_server() — configures agents with url-based MCP entry
('url': 'http://127.0.0.1:9090/mcp/sse') instead of subprocess. Falls back
to stdio injection if SSE fails.
Shared state with proxy: anti-decision DB, session hashes, response cache —
all accessible from SSE MCP tool dispatch (same process, same memory space).
86 tests pass (0 regressions). Zero build warnings.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The MCP server was stdio-only — a separate subprocess with its own memory. No shared state with the proxy (anti-decision, session hashes, response cache). Each agent needed its own subprocess.
Solution
SSE MCP runs on the same axum server as the proxy (port :9090), sharing the same process memory.
Architecture
Shared State
SSE MCP tools and proxy share the same memory space:
Transport Options
| Transport | Config | When |
|---|---|---|
| SSE |
url: http://127.0.0.1:9090/mcp/sse| init default (shared state) || Stdio |
command: reliary-agent mcp| Always-available fallback |Safety
Code Changes
mcp.rs: refactored — extracted puredispatch_tool_call()+tool_definitions()for reusemcp_sse.rs: new (~170 lines) — SSE handler + messages handlerproxy.rs: 2 new routes wired (/mcp/sse,/mcp/messages)init.rs:inject_sse_mcp_server()— URL-based MCP configTests
86 tests pass (0 regressions). Zero build warnings.