Repository navigation
Conversation
…ys (smart-mcp-proxy#1972) Squash of upstream PR smart-mcp-proxy#1972 (not yet merged upstream).
`mcpproxy upstream add-json` decoded the payload into a struct that only named url/command/args/env/headers/working_dir/protocol/trust_mode, so an `oauth` block (and every other key) was dropped while the command reported success. POST /api/v1/servers had no oauth field either, so the block could not reach the daemon by any client. - POST /api/v1/servers accepts `oauth`, validated with OAuthConfig.Validate (400 on a bad block); PATCH, which shares the request type but has no oauth merge, refuses it with 400 instead of decoding and ignoring it. - add-json carries `oauth` on both the daemon and config-file paths, refuses any unknown top-level key (listing them all) and any unknown key inside `oauth`, and accepts `type` as an alias for `protocol` so configs pasted from Claude Desktop / VS Code keep working. - Docs and OpenAPI updated.
4a02a77 to
71c9f11
Compare
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
`upstream import` in daemon mode built the AddServerRequest without the oauth block, so servers imported from claude-code, cursor or gemini files silently lost their oauth settings while the import reported success. Pass s.Server.OAuth through, as the config-file path already did.
…ys (smart-mcp-proxy#1972) Squash of upstream PR smart-mcp-proxy#1972 (not yet merged upstream).
…on create The MCP upstream_servers door runs OAuthConfig.ValidateRefreshReplay on an oauth block; POST /api/v1/servers and upstream add-json only ran Validate, so a refresh_replay_enabled block without an explicit token_endpoint was accepted and then failed config validation on the next load. Run the same check on both doors, and cover a masked client_secret being refused (and not echoed) on create.
|
Thanks @felipecrs — the diagnosis is right and the fix is well scoped. I read the diff end to end, ran the touched packages and the API e2e script, and had it cross-reviewed. Summary: What I verified
What I pushed to your branch (06adc3c, one small commit, normal push): the MCP One decision for the maintainer: unknown top-level keys in Non-blocking nits from the cross-review
Open items
|
Refusing keys the command never applied is a behaviour change for payloads that used to succeed (for example the documented isolation block). Report the sorted dropped keys and the accepted set on stderr and still add the server; an unknown key inside oauth stays refused, since oauth was never carried before. Refusal can follow in the next minor.
|
Pushed two small commits on top of yours (authorship of your commits untouched, no rebase):
Merged |
Head branch was pushed to by a user without write access
|
Thanks for the review and the fixes! I merged |
…ys (smart-mcp-proxy#1972) Squash of upstream PR smart-mcp-proxy#1972 (not yet merged upstream).
Pull Request
Description
mcpproxy upstream add-jsonsilently dropped theoauthblock. The parser only knewurl,command,args,env,headers,working_dir,protocolandtrust_mode, andjson.Unmarshaldiscards anything else, so the command reported success while the server was saved with"oauth": null. It then failed sign-in withOAUTH_NO_CLIENT_ID.POST /api/v1/servershad nooauthfield either, so no client could set OAuth on create through REST.I hit this adding a Home Assistant MCP server. Home Assistant has no Dynamic Client Registration and uses IndieAuth: the
client_idis a URL and the redirect must share its host and port. The server only works with a pinnedclient_idandredirect_uri, and the only ways to set those were editingmcp_config.jsonor theupstream_serversMCP tool.The same drop existed in
upstream import. The daemon-mode path rebuilt each server as anAddServerRequestwithoutoauth, so servers imported from Cursor or Gemini files lost their OAuth settings the same way. Claude Code files will follow in a separate PR, since theiroauthblock needs its own parser.Changes:
POST /api/v1/serversacceptsoauthand validates it with the existingOAuthConfig.Validate(). A bad block gets a 400 before anything is saved. The existing mask check already walks the wholeServerConfig, so it coversoauthtoo.AddServerRequestbut has no oauth merge, so it now refusesoauthwith a 400 instead of decoding and ignoring it. I checked that the Web UI, the macOS app andupstream patchnever sendoauthon PATCH.add-json:oauthon both the daemon and config-file paths and validates it.oauth(DisallowUnknownFields). This is the same class of bug as TPA scanner: unvalidated trust_mode, invisible signature bundle (FR-019 unimplemented), and hold state missing from CLI/UI surfaces #938, now closed for every key, not just one.typeas an alias forprotocol, so configs pasted from Claude Desktop or VS Code keep working. If both are set to different values, it errors.upstream import: the daemon-mode path now carries the parsedoauthblock, matching what the config-file path already did.docs/cli-management-commands.mdlists the accepted keys and adds an OAuth example.oas/was regenerated withmake swagger(swag v2.0.0-rc4).Behavior change: an
add-jsonpayload with keys the command never applied (for exampleenabledorisolation) used to succeed and silently drop them. It now fails with an error that names those keys.Testing
New tests:
TestParseAddJSONOAuthAndUnknownKeysTestUpstreamAddConfigModeKeepsOAuthTestApplyImportedServersDaemonModeCarriesOauthTestHandleAddServer_OAuthTestHandlePatchServer_RefusesOAuthinternal/httpapi,internal/cliclientandinternal/configpass. Incmd/mcpproxy, theTestUpstreamImport*tests andTestApplyNewBinary_*fail on Windows. TheTestUpstreamImport*failures also happen on unchangedmain. I didn't rerunTestApplyNewBinary_*onmain, but they test the self-update binary swap, which this PR doesn't touch.I also ran a built binary end to end against a throwaway config and core:
add-jsonwithoauthsaves the block, both with and without a daemon.redirect_uriis refused on both paths.oauth.PATCHwithoauthreturns 400.golangci-lintwas not run locally; CI will run it.