You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| Backend only accepts API keys or static credentials | Static credentials |[Inject static backend credentials](#inject-static-backend-credentials), [run a server with secrets](./run-mcp-k8s.mdx#run-a-server-with-secrets), or use the [HashiCorp Vault integration](../integrations/vault.mdx)|
55
-
| Backend trusts the same IdP as your clients | Token exchange (RFC 8693) |[Configure token exchange](./token-exchange-k8s.mdx)|
56
-
| Backend trusts a federated IdP (for example, AWS) | Federated token exchange |[AWS STS integration](../integrations/aws-sts.mdx)|
57
-
| Backend is an external API with no federation (for example, GitHub) | Embedded authorization server |[Run an embedded OAuth server](#run-an-embedded-oauth-server)|
| Backend only accepts API keys or static credentials | Static credentials |[Run a server with secrets](./run-mcp-k8s.mdx#run-a-server-with-secrets) or use the [HashiCorp Vault integration](../integrations/vault.mdx) for `MCPServer`; [inject headers into upstream requests](./remote-mcp-proxy.mdx#inject-headers-into-upstream-requests) for `MCPRemoteProxy`|
55
+
| Backend trusts the same IdP as your clients | Token exchange (RFC 8693) |[Configure token exchange](./token-exchange-k8s.mdx)|
56
+
| Backend trusts a federated IdP (for example, AWS) | Federated token exchange |[AWS STS integration](../integrations/aws-sts.mdx)|
57
+
| Backend is an external API with no federation (for example, GitHub) | Embedded authorization server |[Run an embedded OAuth server](#run-an-embedded-oauth-server)|
58
58
59
59
For the full comparison and why each pattern fits its scenario, see
60
60
[Choosing the right backend authentication pattern](../concepts/backend-auth.mdx#choosing-the-right-backend-authentication-pattern).
61
61
62
-
### Inject static backend credentials
63
-
64
-
Use an `MCPExternalAuthConfig` when the MCP server can't read a credential from
65
-
an environment variable, or when you want multiple workloads to share one
66
-
authentication configuration. ToolHive injects the credential into outbound HTTP
67
-
requests at the proxy layer.
68
-
69
-
This differs from [`spec.secrets`](./run-mcp-k8s.mdx#run-a-server-with-secrets)
70
-
and the [HashiCorp Vault integration](../integrations/vault.mdx), which pass
71
-
credentials to the MCP server process as environment variables.
72
-
73
-
Two static credential types are available:
74
-
75
-
-`headerInjection` adds one custom header using `headerName` and a
76
-
`valueSecretRef`.
77
-
-`bearerToken` reads `tokenSecretRef` and adds it as
78
-
`Authorization: Bearer <TOKEN_VALUE>`.
79
-
80
-
First, store the credential in a Secret:
81
-
82
-
```yaml title="backend-api-key-secret.yaml"
83
-
apiVersion: v1
84
-
kind: Secret
85
-
metadata:
86
-
name: backend-api-key
87
-
namespace: toolhive-system
88
-
type: Opaque
89
-
stringData:
90
-
api-key: '<YOUR_API_KEY>'
91
-
```
92
-
93
-
Then create the `MCPExternalAuthConfig`:
94
-
95
-
```yaml title="backend-api-key-auth.yaml"
96
-
apiVersion: toolhive.stacklok.dev/v1beta1
97
-
kind: MCPExternalAuthConfig
98
-
metadata:
99
-
name: backend-api-key
100
-
namespace: toolhive-system
101
-
spec:
102
-
type: headerInjection
103
-
headerInjection:
104
-
headerName: X-API-Key
105
-
valueSecretRef:
106
-
name: backend-api-key
107
-
key: api-key
108
-
```
109
-
110
-
For an `Authorization: Bearer` header, use this configuration instead. Store
111
-
only the token value in the Secret, without the `Bearer` prefix:
112
-
113
-
```yaml title="backend-bearer-auth.yaml"
114
-
apiVersion: toolhive.stacklok.dev/v1beta1
115
-
kind: MCPExternalAuthConfig
116
-
metadata:
117
-
name: backend-bearer-token
118
-
namespace: toolhive-system
119
-
spec:
120
-
type: bearerToken
121
-
bearerToken:
122
-
tokenSecretRef:
123
-
name: backend-bearer-token
124
-
key: token
125
-
```
126
-
127
-
Reference the configuration from an `MCPServer` or `MCPRemoteProxy` in the same
128
-
namespace:
129
-
130
-
```yaml title="MCPServer or MCPRemoteProxy: externalAuthConfigRef"
131
-
spec:
132
-
externalAuthConfigRef:
133
-
name: backend-api-key
134
-
```
135
-
136
-
The same `MCPExternalAuthConfig` can be referenced by multiple workloads. To
137
-
configure headers specifically for one `MCPRemoteProxy`, including multiple
|`initialAccessTokenRef`| References a Secret containing the bearer token that authorizes the registration request. |
651
-
|`softwareId`| Sends an RFC 7591 `software_id` value that identifies the client software independently of a particular registration. |
652
-
|`softwareStatement`| Sends a signed RFC 7591 `software_statement` JWT. The value is visible in the resource and etcd backups, so don't put secrets inside it. |
653
-
654
-
For an initial access token, create a Secret in the same namespace:
655
+
If the upstream provider requires an initial access token, create a Secret in
656
+
the same namespace:
655
657
656
658
```yaml title="dcr-initial-access-token.yaml"
657
659
apiVersion: v1
@@ -664,22 +666,18 @@ stringData:
664
666
token: '<YOUR_DCR_INITIAL_ACCESS_TOKEN>'
665
667
```
666
668
667
-
Then add the reference to the upstream provider's `oauth2Config.dcrConfig` in
668
-
the `MCPExternalAuthConfig`:
669
+
Then add `initialAccessTokenRef` to the upstream provider's
670
+
`oauth2Config.dcrConfig`in the `MCPExternalAuthConfig`. ToolHive sends the
671
+
Secret value as a bearer token when it calls the registration endpoint:
0 commit comments