# Bind MCP Servers to Workload Identities

> Pin an MCP server to a SPIFFE ID at the gateway, not to a name or label. How backendTLS.spiffe and subjectAltNames work in open-source agentgateway.

- Canonical URL: https://webofmike.com/mcp-server-workload-identity/
- Author: Mike Moore (https://webofmike.com/about/)
- Published: 2026-11-29
- Last modified: 2026-11-29
- Tags: MCP, Security, SPIFFE, AI Agents, Platform Engineering
- Cite as: Mike Moore, "Bind MCP Servers to Workload Identities", Web of Mike (webofmike.com), 2026-11-29. https://webofmike.com/mcp-server-workload-identity/


Bind each approved MCP server to a workload identity, not to a name. In open-source [agentgateway](https://agentgateway.dev/), that means sourcing the gateway's own identity from the SPIFFE Workload API with `config.spiffe.endpoint`, turning on `backendTLS.spiffe` for the MCP backend, and pinning that backend's SPIFFE ID in `backendTLS.subjectAltNames`. A registry name, a self-reported server name, or a config label is a claim anyone can copy. A SPIFFE ID in a verified certificate is not. This page is the identity chapter of my [shadow MCP servers](/shadow-mcp-servers/) guide, and it expands the short section on [why bind servers to identities, not labels](/stop-shadow-mcp-servers/).

One scoping note first. This page is about the MCP *server*, the process at the other end of the connection. Who the *caller* is, and the gap in MCP's own auth spec for agents, is [the MCP agent identity gap](/mcp-agent-identity-gap/).

Last checked November 29, 2026, against the agentgateway docs labelled latest (releases through v1.7.0) and MCP specification version 2026-07-28. Every agentgateway behavior below is documented, not tested. I did not run a wrong-identity test for this page.

## Why isn't a server name enough?

A name is something the server or its config file says about itself. A server can report any name. A registry entry matches on the name or ID it was given. A route in a gateway config points at a hostname that DNS or a Kubernetes Service resolves for you.

Each of those can be copied or redirected without anyone holding a key. GitHub's own Copilot registry policy [matches on server name or ID](https://docs.github.com/en/copilot/reference/enterprise-administrators/mcp-private-registry-enforcement) and says that check "can be bypassed by editing configuration files." That is a client-side example, but the gateway side has the same shape. If the only thing tying a route to "our ticketing server" is a hostname, then whatever answers on that hostname is your ticketing server as far as the gateway knows.

The durable check is an identity the workload cannot assert for itself. In [SPIFFE](https://spiffe.io/docs/latest/spiffe-about/spiffe-concepts/), a workload gets a SPIFFE ID (a URI such as `spiffe://example.org/ns/mcp/sa/tickets-mcp`) inside an X.509 SVID, issued after the workload is attested. If you need the definitions, start with [what a SPIFFE ID and an SVID are](/spiffe-id-and-svid/).

## How does an MCP server authenticate, and is that the same thing?

It is not the same thing. The MCP [authorization spec](https://modelcontextprotocol.io/specification/latest/basic/authorization) says plainly that "Authorization is OPTIONAL for MCP implementations." When it is used over an HTTP transport, it authenticates the client to the server: an OAuth flow, often an employee signing in through an identity provider, ending in a bearer token the server checks. The same spec says implementations using stdio "SHOULD NOT follow this specification, and instead retrieve credentials from the environment."

So the shipped auth story answers "may this client call this server?" It does not answer "is this process the server I approved?" A bearer token sent to the wrong process is still a valid token, now in the wrong hands. That is why the server half needs its own check, at the connection, before any token goes out.

The employee side has its own walkthrough: [Cross App Access for MCP](/mcp-oauth-xaa/). For why the spec still says nothing useful about the agent as a principal, read [the MCP agent identity gap](/mcp-agent-identity-gap/).

## How do you bind the server to a SPIFFE ID?

Open-source agentgateway added SPIFFE Workload API support in v1.5. The [v1.5 release notes](https://agentgateway.dev/docs/standalone/1.5.x/release-notes/release-notes/) describe the shape: set `config.spiffe.endpoint` to a local Workload API socket, such as a SPIRE agent, and agentgateway sources its mTLS identity and trust bundle from there instead of from certificate files on disk. The SVID rotates without a restart. Listeners and backends then opt in one at a time with `tls.spiffe` and `backendTLS.spiffe`, and `backendTLS.subjectAltNames` verifies the upstream SPIFFE ID.

Here is that applied to two remote MCP servers behind one gateway. Each target carries its own transport policy, so each server is pinned to its own SPIFFE ID:

```yaml
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
config:
  spiffe:
    endpoint: unix:///run/spire/agent.sock
binds:
- port: 3000
  listeners:
  - name: mcp
    protocol: HTTPS
    tls:
      spiffe: {}
    routes:
    - backends:
      - mcp:
          targets:
          - name: tickets
            mcp:
              host: tickets-mcp.mcp.svc.cluster.local
              port: 8443
              path: /mcp
            policies:
              backendTLS:
                spiffe: {}
                subjectAltNames:
                - spiffe://example.org/ns/mcp/sa/tickets-mcp
          - name: docs
            mcp:
              host: docs-mcp.mcp.svc.cluster.local
              port: 8443
              path: /mcp
            policies:
              backendTLS:
                spiffe: {}
                subjectAltNames:
                - spiffe://example.org/ns/mcp/sa/docs-mcp
```

What each piece does, per the [configuration schema](https://agentgateway.dev/docs/standalone/latest/reference/configuration/schema/):

- `config.spiffe.endpoint` is the SPIFFE Workload API endpoint. When it is set, listeners and backends may source their TLS identity from SPIFFE.
- `tls.spiffe: {}` on the listener sources the gateway's serving identity from the Workload API. It is mutually exclusive with `cert`, `key` and `root`. Callers now need an SVID of their own to connect.
- `policies` on an MCP target holds the transport policy for that target's backend. The schema notes this is not supported on stdio targets.
- `backendTLS.spiffe: {}` makes the gateway present its own SVID to the MCP server and take its trust roots from the Workload API. It is mutually exclusive with `cert`, `key`, `root`, `insecure` and `insecureHost`.
- `backendTLS.subjectAltNames` is the pin. The gateway only accepts the backend certificate if it carries one of the listed SPIFFE IDs.

I checked both YAML blocks on this page against the agentgateway JSON schema for the v1.7.0 release. Both pass. Typos and unknown keys under `backendTLS` fail the same check. Schema-valid is not the same as running, so treat this as a documented starting point, not a tested config.

### What if you leave out subjectAltNames?

This is the detail to remember. The schema says it in one line: "If subjectAltNames is omitted, any SVID chaining to the SPIFFE trust bundle is accepted."

So `backendTLS.spiffe: {}` by itself proves the server is *some* workload in your trust domain. It does not prove it is *the* workload you approved. Any workload holding an SVID in that trust domain, including another team's MCP server or an agent pod, would pass. The [SPIFFE example README](https://github.com/agentgateway/agentgateway/tree/v1.7.0/examples/traffic-spiffe) adds why the hostname cannot save you here: SVIDs carry a `spiffe://` URI SAN and no DNS SAN, so hostname checks do not apply. The pin is the only thing that narrows the trust domain down to one server.

The same README scopes trust to the gateway's own trust domain bundle. Federation across trust domains is not supported, so a server in another trust domain cannot be pinned this way.

The upstream-only form from that README, which works for any HTTP backend, looks like this with an MCP server's ID in the pin:

```yaml
config:
  spiffe:
    endpoint: unix:///run/spire/agent.sock
binds:
- port: 3001
  listeners:
  - name: upstream-mtls
    protocol: HTTP
    routes:
    - policies:
        backendTLS:
          spiffe: {}
          subjectAltNames:
          - spiffe://example.org/ns/mcp/sa/approved-server
      backends:
      - host: approved-server.mcp.svc.cluster.local:8443
```

## How do you identify an MCP server?

Two checks, not one. A protocol probe tells you that a listener speaks MCP: send a discovery request and see whether it answers like an MCP server. That is how you find servers you did not know about, and the full probe is in [how to fingerprint an MCP server](/mcp-server-fingerprinting/).

A pinned SPIFFE ID tells you which workload you reached. The probe finds candidates. The pin decides which of them the gateway will actually talk to. An approved server should pass both, and anything that passes only the first is a candidate for your [MCP registry of record](/mcp-registry-of-record/), not a route.

## What about the caller?

The listener side of the same feature gives you the caller's identity. agentgateway exposes it to policy as `source.spiffeId`, which the [CEL context reference](https://agentgateway.dev/docs/standalone/latest/reference/cel/cel-context/) defines as the first `spiffe://` URI SAN on the downstream client certificate. Unlike `source.identity`, it is populated for any SPIFFE ID, not only the Istio format. Write CEL authorization rules against that value to decide which agents may reach which MCP targets.

That authorizes the caller. It does not pin the server, and neither one replaces the other. [SPIFFE for AI agents, end to end](/spiffe-identity-for-ai-agents/) walks the caller half with a running demo, so I won't repeat it here.

## What does this not cover?

- **stdio servers.** A stdio server is a local process, not a network server. There is no TLS handshake on the MCP transport, so `backendTLS` cannot pin it, and the schema says target policies are not supported on stdio. Contain those with client allowlists and an OS sandbox, covered in the [coding agent MCP allowlist](/coding-agent-mcp-allowlist/) guide.
- **Cloud credentials.** Exchanging a Kubernetes service account token for a cloud credential is [workload identity federation](/workload-identity-federation-agents/), a different job.
- **Vendor-hosted connectors.** A server that never runs in your network has no SVID from your SPIRE server. That limit is covered on [how to stop shadow MCP servers](/stop-shadow-mcp-servers/).

## Methodology

Every agentgateway statement on this page comes from the agentgateway docs labelled latest, the v1.5 release notes, and the SPIFFE example in the agentgateway repository at the v1.7.0 tag, all read on November 29, 2026. Both YAML blocks were validated against the JSON schema published in the agentgateway repository at the v1.7.0 tag, and against the main branch schema the same day. Neither config was run, and I did not run a test where the backend presents the wrong SPIFFE ID, so nothing here is labelled tested. MCP spec quotes are from version 2026-07-28.

