feat: add discovered MCPs as interfaces to codemode - #48
Merged
Conversation
…ed API namespaces Agent code runs in a sandbox where API discovery (codemode.search/describe), documentation search (docs.search/read), and typed per-API namespaces derived from the OpenAPI specs (c8y + one global per tenant service) are available as globals — one find→inspect→call cycle per tool invocation. BREAKING CHANGE: the query and execute MCP tools are removed, the cumulocity sandbox global is gone (escape hatch is now <ns>.request()), and the CLI status tool no longer lists API namespaces.
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.
Stacked on top of #47 (base branch:
feat/codemode-namespaces). Review/merge #47 first.What this adds
Builds on the codemode/namespaces surface from #47 to wrap MCP servers discovered on the tenant as typed namespaces — one typed method per MCP tool — alongside the OpenAPI-derived namespaces.
exposeMcpServersfrom application manifests (type: "http"entries, first valid per contextPath, own contextPath skipped to avoid recursion) and fetches each server's tool list at discovery time. Tool calls run as the end user at runtime via one lazily-opened MCP session per namespace per run.exposeMcpServersandopenApiSpecis wrapped as an MCP namespace and its spec is skipped, with a per-connectionnoMcpopt-out (mc8yp-no-mcpheader /noMcpquery /--no-mcpCLI flag) that falls back to the spec. Both views are kept in the resolved capabilities so the choice happens per connection.src/utils/mcp-client.ts) — streamable-HTTP, tools-only: initialize (empty capabilities),tools/listwith cursor pagination,tools/callwith result unwrap. No elicitation/sampling.kindfield in search results, no protocol markers in describe output, no per-namespace escape hatch.Capability rename
The discovery/resolution layer no longer discovers OpenAPI specs only, so its vocabulary is generalized to capabilities (OpenAPI specs + MCP servers, room for more later):
api-discovery.ts→capability-discovery.ts;discoverApiSpecs→discoverTenantCapabilities,refreshApiSpecs→refreshCapabilities,bustApiSpecCache→bustCapabilityCache,setCachedApiSpecs→setCachedCapabilitiesspec-resolution.ts→capability-resolution.ts;ResolvedSpecs→TenantCapabilities,resolveSpecs→resolveCapabilities,getBundledOnlySpecs→getBundledOnlyCapabilitiesSpec,PathItem,DiscoveredApiSpec, the.specsfield) are intentionally kept.Validation
pnpm typecheckandpnpm test:run(530 passed / 2 skipped) pass. New tests:test/mcp-namespaces.test.ts,test/e2e-mcp.test.ts.