feat: OpenAI-compat /v1 proxy + managed remote MCP server entry#82
Merged
chrysb merged 3 commits intoJun 1, 2026
Merged
Conversation
chrysb
reviewed
May 26, 2026
chrysb
left a comment
Owner
There was a problem hiding this comment.
Review notes from the AlphaClaw pass. The focused and full test suites pass locally, but I think the two P1 items should be addressed before merge.
Two opt-in features for AlphaClaw, both default off; existing
deployments unaffected.
- /v1/chat/completions, /v1/responses, /v1/embeddings, /v1/models[/<id>]
bearer-auth proxy to the loopback gateway. Strips setup cookies +
hop-by-hop response headers + Set-Cookie + Content-Encoding. Enables
gateway.http.endpoints.chatCompletions and responses at managed
onboarding AND backfills on every gateway start.
- mcp.servers.<REMOTE_MCP_NAME> entry driven by REMOTE_MCP_URL +
REMOTE_MCP_API_TOKEN + REMOTE_MCP_PROXY_URL. Token persisted as
${REMOTE_MCP_API_TOKEN} reference, not plaintext. Name validated
([A-Za-z0-9_-]{1,64}, reserved keys rejected). Stale managed
entries cleaned up on rename via _alphaclawManaged marker.
89 test files, 637 passing.
9ed614e to
6b96231
Compare
Contributor
Author
|
Addressed review notes |
chrysb
approved these changes
Jun 1, 2026
chrysb
left a comment
Owner
There was a problem hiding this comment.
Looks good after the explicit API exposure toggle and local verification.
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
Adds two opt-in features that let AlphaClaw front an OpenClaw deployment for OpenAI-compatible clients and for OpenClaw-managed remote MCP servers, without anyone hand-editing
openclaw.json.Both default off. Existing deployments are unaffected until the relevant env vars are set.
1. OpenAI-compatible
/v1/*proxyBearer-auth proxy from AlphaClaw's public Express to the loopback OpenClaw gateway:
POST /v1/chat/completionsPOST /v1/responsesPOST /v1/embeddingsGET /v1/models,GET /v1/models/<id>Lets a self-hosted backend use this AlphaClaw deployment as its OpenAI-compatible endpoint without exposing OpenClaw's gateway port directly.
Authorization: Bearer <OPENCLAW_GATEWAY_TOKEN>. AlphaClaw enforces the header is present; OpenClaw validates the value.Set-Cookiestripped on the way back out.Content-Encodingstripped on forwarded requests because Express has already inflated the body.gateway.http.endpoints.chatCompletions.enabledandresponses.enabledare set in managed-onboarding writes AND backfilled on everygateway start, so existing managed deployments pick up the flags on image bump.2. Env-driven managed
mcp.servers.<name>entryWhen
REMOTE_MCP_URL+REMOTE_MCP_API_TOKENare set, AlphaClaw writes astreamable-httpMCP server block toopenclaw.jsonand keeps it in sync at every gateway start.REMOTE_MCP_URLREMOTE_MCP_API_TOKEN${REMOTE_MCP_API_TOKEN}, not plaintext.REMOTE_MCP_NAMEremotemcp.servers.<name>. Validated^[A-Za-z0-9_-]{1,64}$;__proto__/constructor/prototyperejected.REMOTE_MCP_PROXY_URLREMOTE_MCP_URL. For same-host scanning proxies.Authorizationvalue gets re-scrubbed to the${REMOTE_MCP_API_TOKEN}placeholder on next run._alphaclawManaged: true. IfREMOTE_MCP_NAMEchanges, the prior managed entry is removed. Unmarked (user-managed) entries are never touched.Security boundary
/v1/chat/completionsis an operator-access surface on OpenClaw's side: anyone holdingOPENCLAW_GATEWAY_TOKENcan run any tool the agent profile allows. The README's "Security Notes" section is updated to call this out and to recommend the surface be used only for trusted server-to-server callers.Tests
Test count moves from 619 to 637. New cases cover the
/v1/*proxy (bearer-auth gate, body re-serialize, model-list path, Set-Cookie strip, hop-by-hop strip, Content-Encoding strip) and the managed MCP entry (write with placeholder, route via proxy URL, plaintext scrub, name validation + reserved-key rejection, rename cleanup, user-entry preservation, idempotency, remove-on-unset, gateway-start backfill).npm testclean against Node 22.npm run build:uiunaffected.Backwards compatibility
Defaults unchanged:
/v1/*route only registers when configured, no managed MCP entry without env vars, no schema breaks. Existing tests still pass. The only addition to managed config writes is enabling the chat-completions and responses endpoints (the precondition for #1 to be useful).