Skip to content

feat: add discovered MCPs as interfaces to codemode - #48

Merged
schplitt merged 3 commits into
mainfrom
feat/mcp-interfaces
Jul 23, 2026
Merged

feat: add discovered MCPs as interfaces to codemode#48
schplitt merged 3 commits into
mainfrom
feat/mcp-interfaces

Conversation

@schplitt

@schplitt schplitt commented Jul 17, 2026

Copy link
Copy Markdown
Owner

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.

  • MCP server wrapping — discovery reads exposeMcpServers from 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.
  • Prefer-MCP rule — a service exposing both exposeMcpServers and openApiSpec is wrapped as an MCP namespace and its spec is skipped, with a per-connection noMcp opt-out (mc8yp-no-mcp header / noMcp query / --no-mcp CLI flag) that falls back to the spec. Both views are kept in the resolved capabilities so the choice happens per connection.
  • Minimal MCP client (src/utils/mcp-client.ts) — streamable-HTTP, tools-only: initialize (empty capabilities), tools/list with cursor pagination, tools/call with result unwrap. No elicitation/sampling.
  • Backing protocol is invisible to the agent by design — no kind field 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.tscapability-discovery.ts; discoverApiSpecsdiscoverTenantCapabilities, refreshApiSpecsrefreshCapabilities, bustApiSpecCachebustCapabilityCache, setCachedApiSpecssetCachedCapabilities
  • spec-resolution.tscapability-resolution.ts; ResolvedSpecsTenantCapabilities, resolveSpecsresolveCapabilities, getBundledOnlySpecsgetBundledOnlyCapabilities
  • Genuinely OpenAPI-specific names (Spec, PathItem, DiscoveredApiSpec, the .specs field) are intentionally kept.

Validation

pnpm typecheck and pnpm test:run (530 passed / 2 skipped) pass. New tests: test/mcp-namespaces.test.ts, test/e2e-mcp.test.ts.

schplitt added 2 commits July 13, 2026 21:36
…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.
Base automatically changed from feat/codemode-namespaces to main July 22, 2026 13:17
@schplitt
schplitt merged commit 290fcca into main Jul 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant