feat(engine): gateway transport (config + hand-rolled MCP client) - #14
Merged
Conversation
Additive first slice of the thin-engine re-scope. sealg forwards tool calls
to the SealGate gateway's per-user /mcp/{api_key}/ endpoint, where all policy
and trifecta enforcement lives; the binary carries none.
- gateway::config: GatewayConfig::from_env resolves gateway URL, optional API
key (path vs upstream-injected auth), sealgate_secret_key, conversation id
(SEALGATE_CONVERSATION_ID or CENTAUR_THREAD_KEY), and MITM CA bundle. Written
against a getter seam for deterministic tests.
- gateway::client: hand-rolled MCP Streamable HTTP (2026-07-28) client -
initialize/tools_list/tools_call, session-id capture, JSON + SSE response
parsing, MCP-shaped errors mapped verbatim (design B3). No rmcp dep.
- 10 unit tests (env resolution, URL building, JSON/SSE/error parsing); fmt +
clippy clean.
Not yet wired into the CLI surface; demo commands still present. Next slice
rewires 'sealg call' to the gateway, adds 'sealg list', deletes demo commands.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EpwFmgQPfugKFF9zugay6Y
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
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.
Summary
First slice of the thin-engine re-scope:
sealgbecomes a thin transport that forwards tool calls to the SealGate gateway's per-user/mcp/{api_key}/endpoint, where all policy / lethal-trifecta / PII enforcement lives. The binary carries no policy of its own.This PR is additive — it adds the gateway transport module but does not yet wire it into the CLI surface, so nothing existing breaks. The follow-up slice rewires
sealg call→ the gateway, addssealg list, and deletes the template's local demo commands.Design context:
dev-docs/architecture/multi-interface-design.mdinedison-watch/edison-watch(§5A thin engine, §5B Centaur, B3 error mirroring).Changes
crates/engine/src/gateway/config.rs—GatewayConfig::from_env()resolves gateway coordinates from the environment (so the binary stays stateless and drops into any sandbox):SEALGATE_URL, defaults to the dev endpoint — never a guessed prod host)/mcp/{key}/path; absent → keyless path, auth injected upstream (Centaur iron-proxy). Supports both credential models with no fork.sealgate_secret_keyheader value, conversation id (SEALGATE_CONVERSATION_ID, falling back to Centaur'sCENTAUR_THREAD_KEY), and a MITM CA bundle (SSL_CERT_FILE/REQUESTS_CA_BUNDLE/NODE_EXTRA_CA_CERTS) — reqwest+rustls does not read those automatically, so we load them or TLS fails behind an intercepting proxy.crates/engine/src/gateway/client.rs— hand-rolled MCP Streamable-HTTP client (spec 2026-07-28), normcpdependency so the binary stays thin:initialize/tools_list/tools_call,Mcp-Session-Idcapture, JSON + SSE response parsing, and JSON-RPC errors mapped to a variant that mirrors the MCP error shape verbatim (no bespoke taxonomy).crates/engine/src/gateway/mod.rs+lib.rs— module wiring and re-exports.Testing
cargo test -p engine gateway: 10 passed (env resolution, URL building, JSON/SSE/error parsing). The client's transport methods need a live gateway, so this slice unit-tests the pure pieces (config resolution, the response parser).cargo fmt --checkandcargo clippy -p engineclean locally. Fullmake ciruns here on CI.Related Issues
None — tracked by the multi-interface design doc.
Generated by Claude Code
Summary by cubic
Turns
sealginto a thin transport that forwards tool calls to the SealGate gateway's per-user/mcp/{api_key}/endpoint, where all policy and PII enforcement lives. Additive only — the CLI surface is unchanged and nothing existing breaks.GatewayConfig::from_env()reads gateway URL, API key, secret key, conversation id, and MITM CA bundle from the environment./mcp/{key}/; without one, auth is injected upstream and the keyless path is used; conversation id falls back toCENTAUR_THREAD_KEY.rmcpdependency.Written for commit ed6fd11. Summary will update on new commits.