Skip to content

feat(workspaces): Kubernetes workspaces give their pods MCP servers - #1767

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

edenreich merged 2 commits into
mainfrom
feat/workspace-mcp-servers

Conversation

@edenreich

@edenreich edenreich commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

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:

# ~/.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

Cross-repo impact

A Kubernetes workspace's mcp_servers names hosted servers of this
machine's ~/.infer/mcp.yaml its pods get. When a session's Orchestrator
is created, each one goes into spec.mcp.hostedServers with its name, URL
and headers, and MCP is switched on for the pod.

mcp.yaml is read as written, so a header stays a ${VAR} reference the
pod expands from the workspace's Secrets. A header that holds a value, a
container server and a name mcp.yaml lacks fail before the Orchestrator
is created, so no secret lands in a Kubernetes object. An operator that
refuses the field fails the create with the upgrade error naming the
release that renders hosted servers.

The session-teleport example gains a k8s-mcp workspace with the demo MCP
server deployed in the cluster.

Closes #1760
…ervers

The operator gives the pod MCP servers through spec.mcp.servers entries
with a name, a URL and headers, so the Orchestrator carries them there.
An older operator types those entries as strings and refuses them as
invalid, which now also reads as the upgrade error.
@edenreich
edenreich marked this pull request as ready for review November 8, 2026 22:22
@edenreich
edenreich requested a review from a team as a code owner November 8, 2026 22:22
@edenreich
edenreich merged commit 1d82267 into main Nov 8, 2026
1 check passed
@edenreich
edenreich deleted the feat/workspace-mcp-servers branch November 8, 2026 22:27
edenreich added a commit that referenced this pull request Nov 8, 2026
…operator's api/v1alpha1 (#1770)

## Summary

The Kubernetes workspace adapter copied the Orchestrator's status
contract as string literals, so a renamed value in the operator would
break a teleport without a compile error. Operator v0.33.0 exports the
contract from `api/v1alpha1` (inference-gateway/operator#322), and the
adapter now reads it from there:

- `readyCondition` in `workspace.go` matches the condition type
`OrchestratorConditionReady`.
- `unrecoverableReasons` in `workspace.go`, the reasons a teleport fails
fast on, are `ReasonSandboxCRDMissing` and `ReasonInvalidSpec`.
- `ReportIdle` in `self.go` writes `AgentsDoneMessage` when every agent
is done.

The fail-fast list keeps the same two reasons. Their doc comments in the
operator say they need a change to the cluster or the spec.
`ReasonSandboxSuspended` needs a spec change too, but `awaitReady` makes
it itself by resuming the Orchestrator, and the doc comment now says so.
`GatewayNotFound`, `SandboxNotReady` and `DeploymentNotAvailable` can
clear on their own, so a teleport keeps waiting on them.

Closes #1769

## Dependency

- `go.mod` requires `github.com/inference-gateway/operator` v0.33.0. It
uses the same `k8s.io` v0.37.2 modules as the CLI, adds
`sigs.k8s.io/gateway-api` as an indirect dependency, and moves
`github.com/google/gnostic-models` from v0.7.0 to v0.7.1.
- The stripped `purego` binary grows by about 0.87MB, from 81.92MB to
82.79MB.
- The `kubernetes-only-in-the-kubernetes-adapters` depguard rule now
also confines `github.com/inference-gateway/operator` to the two
Kubernetes adapters. An import from `internal/sessions` is refused by
that rule.
- `operatorv1alpha1` joins the canonical aliases in `AGENTS.md`, and
`internal/agent/README.md` names the operator's API types beside
client-go.

## Compatibility

The values are unchanged, so every operator release that reports them
keeps working. The workspace tests still build their fake Orchestrators
and expected termination messages from the literal strings, so they pin
the wire values the adapter has to match.

## Verification

- `task test` passes.
- `task test:e2e`: every test passes except
`TestChatTUIAnswersAQuestion`, which failed in both full runs. It is
flaky without this change: run alone, it failed one of three runs on the
commit before #1767 and one of three on main. It
passes when run alone on this branch twice.
- `task precommit:run` passes.

no docs ticket: internal-only refactor
@edenreich edenreich moved this from Todo to Done in 2026 Nov 8, 2026
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.250.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Nov 9, 2026
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

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEATURE] Kubernetes workspaces give their pods MCP servers

1 participant