Repository navigation
Conversation
…m a)
Add apis_add (POST /v1/apis) and apis_remove (DELETE /v1/apis/{name})
following the adapters_add pattern from PR #2565: persist the
declaration into the first paths.apis file that names API files and
reload, so the API is callable immediately and survives restart;
refuse with a remedy when no API file is configured, on cross-file
duplicates, and on server-namespace collisions.
CLI: mcpx api add <name> --spec <doc> [...] and mcpx api remove
<name> go through the daemon like adapter add/remove. Regenerated
ops.gen.ts and docs/parity.md; the api manual entry now lists
add/remove and drops the stale local-only note.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 38 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 91021b4eb9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if srv == nil || config.SanitizeNamespace(name) != want { | ||
| continue |
There was a problem hiding this comment.
Check resolved namespaces before persisting an API
When an existing server uses an explicit mcpx.namespace, this comparison checks its name instead of its actual namespace. For example, a server named backend with mcpx.namespace: "pets" allows an API named pets past this check. The declaration is then persisted, but the reload fails because Config.ResolveAll rejects the duplicate resolved namespace. Since the write is not rolled back, subsequent reloads and daemon starts also fail until the declaration is removed. Compare against the existing servers’ resolved namespaces before writing.
Useful? React with 👍 / 👎.
| body := map[string]any{ | ||
| "name": name, "spec": *spec, "replace": *replace, |
There was a problem hiding this comment.
Resolve local spec paths before sending them to the daemon
When the CLI runs from a directory different from the running daemon’s working directory, mcpx api add petstore --spec ./petstore.json persists the caller-relative path unchanged. The generated API server has no explicit working directory, so its default global instance inherits the daemon’s directory, and openapi.Load reads the relative path directly. Consequently, add reports success but the API either cannot load its document or loads an unrelated document at the same relative path. Resolve local spec paths against the CLI’s working directory before constructing the request, while preserving URL handling.
Useful? React with 👍 / 👎.
| if err := json.Unmarshal([]byte(trimmed), &doc); err != nil { | ||
| return nil, false, nil, fmt.Errorf("%s is not a valid API file: %w", path, err) |
There was a problem hiding this comment.
Preserve exact numbers when reading combined API documents
When an API declaration file also contains server configuration, decoding the whole document into map[string]any with json.Unmarshal converts sibling numeric values to float64. Every API add or remove then serializes that entire document, silently changing values such as a tool-view pinned ID of 9007199254740993 to 9007199254740992. After reload, calls through that view forward the wrong ID. config.parse already uses Decoder.UseNumber specifically to preserve these pins; use equivalent number-preserving decoding here so editing APIs does not corrupt unrelated configuration.
Useful? React with 👍 / 👎.
|
Correction to the test summary above: the full |
Implements #2118 item (a): the API-spec write side.
What
apis_add) + DELETE /v1/apis/{name} (apis_remove) inpkgs/mcpx/internal/daemon/routes_settings.go, following theadapters_addpattern (PR feat(mcpx): live add/remove for adapter declarations (#2118) #2565): persist the declaration into the firstpaths.apisfile and reload, so the API is callable immediately and survives restart. Refuses with remedy when no API file is configured, on cross-file duplicates, and on server-namespace collisions.AddAPIEntry/RemoveAPIEntry/APIDefinedInininternal/config/write.go, preserving bare-array vs{"apis": [...]}shape and sibling sections of combined documents.Command: "api add"/"api remove"(PermissionAdmin,Admin,Mutating, +Destructive/Idempotenton remove), so the routes are also reachable over MCP (mcpx_apis_add/mcpx_apis_remove) and the plugin client (ops.apisAdd()/ops.apisRemove()).mcpx api add <name> --spec <doc> [--base-url ...] [--include ...] [--exclude ...] [--methods ...] [--deprecated] [--header K=V]... [--description ...] [--replace]andmcpx api remove <name>, through the daemon like adapter add/remove.plugin/opencode/mcpx/ops.gen.ts,docs/parity.md,flagindex_generated.go;apimanual entry lists add/remove and drops the stale local-only note (already false since augmentAPIs, PR feat(mcpx): declared OpenAPI APIs are first-class servers (#2118) #2514).Tests
internal/config:write_apis_test.go(create/duplicate/replace, bare-array shape, sibling-section preservation)internal/daemon:api_routes_test.go(validation, no-file remedy, cross-file dup, replace-edits-defining-file, add+remove round trip, 404 on unknown, concurrency, namespace collision)internal/cli:api_add_test.go(flag hoisting,--headerparsing)go test ./...green on the laptop for all ofpkgs/mcpx; targeted e2e generated-command tests pass.Closes #2118 item (a). Recipe live-add was already present (verified, untouched); bare-binary generated declarations remain with the sibling packet coordinating with #1962.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.