Skip to content

feat(orchestrator): give spec.mcp.servers names and headers in the pod's mcp.yaml - #324

Merged
edenreich merged 2 commits into
mainfrom
feat/orchestrator-hosted-mcp-servers
Nov 8, 2026
Merged

edenreich merged 2 commits into
mainfrom
feat/orchestrator-hosted-mcp-servers

Conversation

@edenreich

@edenreich edenreich commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

An Orchestrator gives its pod MCP servers by URL with the headers they authenticate by, through spec.mcp.servers:

spec:
  env:
    - name: MCP_EXAMPLE_API_KEY
      valueFrom:
        secretKeyRef:
          name: mcp-example-credentials
          key: MCP_EXAMPLE_API_KEY
  mcp:
    enabled: true
    servers:
      - name: example
        url: https://mcp.example.com/mcp
        headers:
          x-api-key: ${MCP_EXAMPLE_API_KEY}
  • spec.mcp.servers becomes a list of {name, url, headers}, the shape a Gateway's servers take. It is a list map keyed on name, so the API server refuses two servers with one name.
  • The pod's mcp.yaml is rendered and its ConfigMap mounted whenever spec.mcp.enabled is true and a server is listed, with or without service discovery.
  • Header values reach the ConfigMap exactly as given, so ${VAR} stays a reference the infer CLI in the pod expands from its environment, which spec.env fills from a Secret. The operator never resolves a secret into the ConfigMap or the Orchestrator.
  • Each entry carries name, enabled, url and headers. The split scheme/host/port/path and the URL parsing behind them are gone, since the CLI reads url since v0.248.0.
  • The document is rendered with a YAML encoder (sigs.k8s.io/yaml) rather than string concatenation, so a header value cannot break or inject YAML.
  • The existing hash annotation rolls the pod when the rendered mcp.yaml changes, on both the Deployment and the Sandbox runtime.

Closes #321

  • spec.mcp.servers no longer takes plain URL strings. An Orchestrator listing them fails validation until each entry has a name and a url.
  • The pod needs an infer image of v0.248.0 or newer, which reads url. Older images no longer find the split fields.
  • Orchestrators that already render mcp.yaml through discovery roll their pod once after the upgrade.

Tests

  • buildMCPsYAML specs strictly decode the rendered document into the CLI's field names, so a key the CLI does not declare fails. They cover the empty document, servers with headers kept as given (a value that looks like YAML included), and the order: servers in spec order, then discovered MCPs by name with their status, TLS and fallback URLs.
  • An envtest spec reconciles an Orchestrator with a server and no discovery, and checks the ConfigMap, the mount and the hash annotation.
  • task test, the strict decode of every example and a clean task generate and task manifests pass.

Verified on a cluster

On a throwaway k3d cluster with the controller from this branch's first revision and ghcr.io/inference-gateway/cli:latest (infer v0.249.0). That revision named the list hostedServers and also wrote the split fields, the rendering is otherwise the same:

  • The <name>-mcps ConfigMap and the pod's mounted ~/.infer/mcp.yaml held the header as ${MCP_TIME_API_KEY}. The Secret's value was in neither the ConfigMap nor the Orchestrator.
  • infer mcp status in the pod reported the server connected with its 4 tools.
  • Changing the server rolled the pod.
  • A listener behind a second server logged the pod's request with X-Api-Key: demo-key-from-the-secret, so the pod expands the reference from its Secret.

The check used the demo server of inference-gateway/cli (examples/mcp/mcp-server). The operator's own example servers do not connect, see the known gap below.

Example and docs

  • examples/orchestrator lists time-direct under spec.mcp.servers: an MCP CR without a discovery label, reached by URL with an x-api-key header read from the mcp-time-credentials Secret through spec.env.
  • The README documents spec.mcp.servers beside Orchestrator-side discovery.

Known gaps

Cross-repo impact

…to the pod's mcp.yaml

spec.mcp.hostedServers gives the pod MCP servers by URL under a name of
their own, with the headers they authenticate by. Header values reach
the ConfigMap as given, so a ${VAR} stays a reference the infer CLI in
the pod expands from its environment.

The pod's mcp.yaml is rendered and mounted whenever MCP is enabled and a
static or hosted server is listed, with or without service discovery. A
YAML encoder writes it, and every entry carries url and headers beside
the split scheme, host, port and path older CLIs read.

Closes #321
…ad of a second list

spec.mcp.servers becomes a list of {name, url, headers}, the shape a
Gateway's servers take, and hostedServers is gone. Plain URL strings are
no longer accepted.

The pod's mcp.yaml carries only name, enabled, url and headers, since the
CLI reads url since v0.248.0, so the split scheme, host, port and path go
with the URL parsing behind them.
@edenreich edenreich changed the title feat(orchestrator): render hosted MCP servers with url and headers into the pod's mcp.yaml feat(orchestrator): give spec.mcp.servers names and headers in the pod's mcp.yaml Nov 8, 2026
@edenreich
edenreich merged commit 56f4ff8 into main Nov 8, 2026
1 check passed
@edenreich
edenreich deleted the feat/orchestrator-hosted-mcp-servers branch November 8, 2026 21:13
inference-gateway-releaser Bot added a commit that referenced this pull request Nov 8, 2026
## [0.33.0](v0.32.0...v0.33.0) (2026-11-08)

### ✨ Features

* **gateway:** tune MCP health polling with spec.mcp.healthCheck ([#328](#328)) ([ff0867c](ff0867c))
* **orchestrator:** give spec.mcp.servers names and headers in the pod's mcp.yaml ([#324](#324)) ([56f4ff8](56f4ff8)), closes [#321](#321)
* **orchestrator:** pass through binding Service annotations and labels ([#320](#320)) ([d543db8](d543db8))

### ♻️ Improvements

* **orchestrator:** export the status contract from api/v1alpha1 ([#330](#330)) ([4b5d854](4b5d854))

### 🐛 Bug Fixes

* **examples:** serve the example MCP servers over stateless MCP 2026-07-28 ([#325](#325)) ([6d34978](6d34978)), closes [#323](#323)
* **samples:** make the Gateway and MCP samples pass CRD validation ([#329](#329)) ([e2e5d2a](e2e5d2a))

### 👷 CI

* **deps:** bump the gomod group with 4 updates ([#319](#319)) ([67f1bde](67f1bde))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.33.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Nov 8, 2026
edenreich added a commit to inference-gateway/cli that referenced this pull request Nov 8, 2026
…1767)

## Summary

A Kubernetes workspace names the hosted MCP servers of this machine's
`~/.infer/mcp.yaml` its pods get, and the adapter writes them into each
new Orchestrator:

```yaml
# ~/.infer/mcp.yaml
servers:
  - name: agentmail
    enabled: true
    url: https://mcp.agentmail.to/mcp
    headers:
      x-api-key: ${AGENTMAIL_API_KEY}

# ~/.infer/daemon.yaml
workspaces:
  - name: code-reviewer
    kind: kubernetes
    namespace: agents
    image: ghcr.io/inference-gateway/cli:latest
    secrets:
      - code-reviewer-credentials
    mcp_servers:
      - agentmail
```

- `mcp_servers` is accepted on a Kubernetes workspace, also one placed
on a cluster through `compute`. Any other kind fails validation, like
`secrets`.
- When a session's Orchestrator is created, each named server goes into
`spec.mcp.servers` with its name, URL and headers, and
`spec.mcp.enabled` is set.
- `mcp.yaml` is read as written (`LoadMCPForEdit`), so a header stays a
`${VAR}` reference the pod expands from its own `secrets`. A header that
holds a value rather than a reference is refused with an error naming
the server and the header, never the value, so no secret lands in a
Kubernetes object.
- A name `mcp.yaml` lacks and a container server (`run: true`) fail with
an error naming the server before the Orchestrator is created.
- An older operator types `spec.mcp.servers` entries as strings and
refuses the create as invalid. That now also reads as the existing "may
predate ..., upgrade it" error, naming v0.33.0.
- The servers are read when the Orchestrator is created, like `secrets`,
so running sessions keep theirs.

Closes #1760

## Draft: waiting on the operator

This writes `spec.mcp.servers` entries with a `name`, a `url` and
`headers`, the shape inference-gateway/operator#324 gives the field,
which no operator release has yet. Until it ships, a workspace with
`mcp_servers` fails its teleport with the upgrade error and every other
workspace is unaffected. `newFieldsOperatorVersion` is v0.33.0, the next
operator release, which `binding_service` already needs. It has to
follow the release operator#324 actually lands in.

## Tests

- `TestCreateGivesThePodTheNamedMCPServersAsWritten` runs `create`
against a fake cluster: no servers leaves `spec.mcp` unset, named
servers carry their URLs and header references (a URL built from scheme,
host, port and path included), and a missing name, a container server
and a header holding a value fail without creating anything. The
header's variable is set in the test's environment, and its value never
reaches the Orchestrator.
- `TestCreateNamesTheOperatorVersionMCPServersNeed` checks the upgrade
error when an older operator refuses the entries as invalid. The 422
there is modeled on the apiserver's schema error, not captured from a
live older operator.
- Config tests cover `mcp_servers` on a local workspace and on a
workspace placed through `compute`.
- `task test:e2e`, `task precommit:run` and `go test ./...` pass. The
e2e suite does not run Kubernetes workspaces, and no cluster with an
operator that renders hosted servers exists yet.

## Example and docs

- `examples/session-teleport` gains a `k8s-mcp` workspace. It gets the
demo MCP server from `examples/mcp`, deployed into the cluster with
`task mcp:install`, behind an `x-api-key: ${DEMO_MCP_KEY}` header the
pod fills from the `demo-mcp-credentials` Secret. `task mcp:status` runs
`infer mcp status` in the pod. The walkthrough states it needs operator
v0.33.0 or newer.
- `docs/daemon.md` documents `mcp_servers` beside `secrets`, with the
AgentMail example.

## Known gaps

- A refusal fails after the session's TLS Secret exists, as a missing
`secrets` entry already does. A retry reuses it.
- A `${VAR}` in a server's `port` still cannot be read as written, the
gap noted in #1765.

## Cross-repo impact

- `operator`: inference-gateway/operator#324 renders `spec.mcp.servers`
into the pod's `mcp.yaml`. This PR depends on it.
- `desktop`: inference-gateway/desktop#480 writes `mcp_servers` under a
workspace in `daemon.yaml`, the shape this reads.
- `docs`: inference-gateway/docs#1146 documents `mcp_servers` on
Kubernetes workspaces.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Orchestrator: render static MCP servers with url and headers into the pod's mcp.yaml

1 participant