Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/conformance/baseline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
server:
# The streamable-HTTP endpoint is stateless (WithStateLess), so a
# 2025-11-25 initialize hands out no Mcp-Session-Id; the runner warns.
- server-sse-multiple-streams:server-sse-multiple-streams-session
58 changes: 58 additions & 0 deletions .github/workflows/conformance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: MCP conformance

on:
pull_request: {}
merge_group: {}
push:
branches: ['main']

permissions: {}

concurrency:
group: conformance-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
server:
name: MCP conformance
runs-on: ubuntu-26.04
permissions:
contents: read
env:
LISTEN: 127.0.0.1:38591
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version-file: go.mod
- name: Find the mcp-toolkit version in go.mod
id: toolkit
run: echo "version=$(go list -m -f '{{.Version}}' github.com/giantswarm/mcp-toolkit)" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: giantswarm/mcp-toolkit
ref: ${{ steps.toolkit.outputs.version }}
path: .mcp-toolkit
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .mcp-toolkit/conformance/.nvmrc
cache: npm
cache-dependency-path: .mcp-toolkit/conformance/package-lock.json
- name: Start the server
run: |
go build -o "$RUNNER_TEMP/server" .
"$RUNNER_TEMP/server" serve --listen "$LISTEN" &
- name: Run the conformance scenarios
env:
CONFORMANCE_BASELINE: ${{ github.workspace }}/.github/conformance/baseline.yml
CONFORMANCE_RESULTS: ${{ runner.temp }}/results
run: .mcp-toolkit/conformance/run.sh "http://$LISTEN/mcp"
- if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: conformance
path: ${{ runner.temp }}/results
retention-days: 7
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ Owns the Agent Platform's skill sources: lists their skills and pins skills and
- Tools: [docs/tools.md](docs/tools.md)
- REST API: [docs/api.md](docs/api.md)
- Configuration: the chart's [values](helm/skill-manager/values.yaml) — `sources`, `github`, `cacheTTL`, `oauth`, `muster.mcpServer`, `serviceToken`.
- Upgrading: see [UPGRADE.md](UPGRADE.md) for what each release asks of an operator.
- OAuth: mcp-oauth's `OAUTH_*` variables (`oauthconfig.SettingsFromEnv`), rendered from `oauth.resourceServer` and `oauth.authorizationServer`. The MCP endpoint is stateless; `MCP_ALLOWED_HOSTS` and `MCP_ALLOWED_ORIGINS` (`mcp.allowedHosts`, `mcp.allowedOrigins`) admit a proxy's host and browser origins.
68 changes: 68 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Upgrade notes

What an operator has to do or decide when upgrading, newest first. The
release notes on GitHub list every change; this file covers the actions.

A section is headed with the version that ships it (`## 0.6.0 — <title>`).
A pull request that adds notes heads them `## Next — <title>`; the release
renames each `Next` to its version.

## Next — chart values on model-manager's layout

The chart takes mcp-oauth's value names for MCP servers (`oauth.resourceServer`,
`oauth.authorizationServer`). The old names keep working, deprecated; the install
notes list each old name a release sets. Move to the new names before the release
that removes the old ones.

| Old | New |
|---|---|
| `oauth.baseURL` | `oauth.authorizationServer.issuer` |
| `oauth.dex.issuerURL` | `oauth.authorizationServer.upstream.issuer` |
| `oauth.dex.clientID` | `oauth.authorizationServer.upstream.client.id` |
| `oauth.dex.clientSecret`, `oauth.existingSecret` | `oauth.authorizationServer.upstream.client.secretKeyRef` |
| `oauth.dex.caSecret` | `oauth.authorizationServer.upstream.certificateAuthority.secretKeyRef` |
| `oauth.trustedAudiences` | the `audiences` of an `oauth.resourceServer.trustedIssuers` entry |
| `oauth.sso.allowPrivateIPJWKSHosts` | the `allowPrivateIPJWKSHosts` of an `oauth.resourceServer.trustedIssuers` entry |
| `oauth.allowPublicClientRegistration` | nothing: MCP clients register with client ID metadata documents |
| `oauth.dex.allowPrivateURLs`, `oauth.sso.allowPrivateIPs` | nothing: they have no effect |
| `networkPolicy.ingressNamespaces` | a `networkPolicy.gatewayPeers` entry with a `namespaceSelector` |
| `networkPolicy.metricsNamespaces` | a `networkPolicy.metricsPeers` entry |

- **Configuration through `OAUTH_*` variables.** The chart renders mcp-oauth's
`OAUTH_*` variables instead of the flags, and mounts the Dex client secret as a
file instead of `DEX_CLIENT_SECRET`. Dex becomes an `OAUTH_TRUSTED_ISSUERS`
entry marked as the OpenID Provider, accepting the same audiences. Outside the
chart, the old flags and variables (`--oauth-base-url`, `--dex-*`,
`--oauth-trusted-audiences`, `--sso-allow-private-ip-jwks-hosts`,
`--allow-public-client-registration` and their variables) keep working, log a
warning naming the replacement, and lose to an `OAUTH_*` variable.
- **Trusted issuers and a private Dex.** The entry the chart builds for Dex lists
the issuer host in `allowPrivateIPJWKSHosts`. An entry you write in
`oauth.resourceServer.trustedIssuers` is used as written: list a private JWKS
host in it, or every forwarded token is refused with 401.
- **No authorization server of its own.** When every caller brings a token from a
trusted issuer, as muster, agent-manager and the portal do, set
`oauth.authorizationServer.enabled: false` and list that issuer in
`oauth.resourceServer.authorizationServers`. The Dex client and its secret are
then not needed. `oauth.authorizationServer.issuer` stays set: it is the
server's public URL.
- **Token introspection.** `/oauth/introspect` is no longer served. Set
`OAUTH_ENABLE_INTROSPECTION_ENDPOINT=true` in `extraEnv` if a client uses it.
- **Who may reach the server.** The NetworkPolicy admits muster, agentgateway
and agent-manager in the release namespace (`networkPolicy.gatewayPeers`)
instead of every pod there, and the `alloy-metrics` scraper in `kube-system`
(`networkPolicy.metricsPeers`) instead of every pod in `kube-system`. A caller
in the release namespace with another `app.kubernetes.io/name` needs a
`gatewayPeers` entry. Namespaces listed in the deprecated
`ingressNamespaces` and `metricsNamespaces` stay admitted.
- **ServiceMonitor tenant.** `serviceMonitor.labels` defaults to
`observability.giantswarm.io/tenant: giantswarm`, and a ServiceMonitor without
that label fails to render.
- **HTTPRoute.** `httpRoute.*` renders an optional Gateway API route, off by
default.
- **Stateless endpoint.** `/mcp` hands out no `Mcp-Session-Id`; any replica
answers any request.
- **Browser and proxy access.** `/mcp` refuses cross-origin browser requests and,
on a loopback listener, a foreign `Host`. A proxy in the same pod that keeps the
public host needs `mcp.allowedHosts`; a web application on another origin
needs `mcp.allowedOrigins`.
116 changes: 116 additions & 0 deletions cmd/oauth_env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package cmd

import (
"errors"
"log/slog"
"os"
"strconv"

"github.com/giantswarm/mcp-oauth/oauthconfig"
)

// deprecatedOAuthOption is a flag whose setting mcp-oauth's OAUTH_* variable
// Replacement holds. Env is the variable that also sets the flag, if any.
type deprecatedOAuthOption struct {
Flag string
Env string
Replacement string
}

// oauthEnvironment returns the OAUTH_* variables to set before
// oauthconfig.SettingsFromEnv reads them: each deprecated option's value under
// its replacement, then skill-manager's defaults. A variable lookup finds
// wins over both. The second result lists the deprecated options in use.
func oauthEnvironment(o *serveOptions, lookup func(string) (string, bool)) (map[string]string, []deprecatedOAuthOption) {
set := map[string]string{}
var deprecated []deprecatedOAuthOption
present := func(name string) bool {
if _, ok := set[name]; ok {
return true
}
for _, candidate := range []string{name, name + "_FILE"} {
if v, ok := lookup(candidate); ok && v != "" {
return true
}
}
return false
}
value := func(name string) string {
if v, ok := set[name]; ok {
return v
}
v, _ := lookup(name)
return v
}

authorizationServer := true
if raw, ok := lookup("OAUTH_ENABLE_AUTHORIZATION_SERVER"); ok {
if parsed, err := strconv.ParseBool(raw); err == nil {
authorizationServer = parsed
}
}
publicRegistration := ""
if o.allowPublicClientRegistration {
publicRegistration = "true"
}
for _, option := range []struct {
deprecatedOAuthOption
value string
}{
{deprecatedOAuthOption{"oauth-base-url", "SKILL_MANAGER_OAUTH_BASE_URL", "OAUTH_ISSUER"}, o.oauthBaseURL},
{deprecatedOAuthOption{"dex-issuer-url", "DEX_ISSUER_URL", "OAUTH_DEX_ISSUER_URL"}, o.dexIssuerURL},
{deprecatedOAuthOption{"dex-client-id", "DEX_CLIENT_ID", "OAUTH_DEX_CLIENT_ID"}, o.dexClientID},
{deprecatedOAuthOption{"dex-client-secret", "DEX_CLIENT_SECRET", "OAUTH_DEX_CLIENT_SECRET"}, o.dexClientSecret},
{deprecatedOAuthOption{"dex-ca-file", "DEX_CA_FILE", "OAUTH_DEX_CA_FILE"}, o.dexCAFile},
{deprecatedOAuthOption{"oauth-trusted-audiences", "", "OAUTH_TRUSTED_AUDIENCES"}, o.oauthTrustedAudiences},
{deprecatedOAuthOption{"sso-allow-private-ip-jwks-hosts", "SSO_ALLOW_PRIVATE_IP_JWKS_HOSTS", "OAUTH_ALLOW_PRIVATE_IP_JWKS_HOSTS"}, o.ssoAllowPrivateIPJWKSHosts},
{deprecatedOAuthOption{"allow-public-client-registration", "SKILL_MANAGER_OAUTH_ALLOW_PUBLIC_REGISTRATION", "OAUTH_ALLOW_PUBLIC_CLIENT_REGISTRATION"}, publicRegistration},
} {
// The flag's default is the replacement itself when Env is empty.
if option.value == "" || option.value == value(option.Replacement) {
continue
}
deprecated = append(deprecated, option.deprecatedOAuthOption)
if !present(option.Replacement) {
set[option.Replacement] = option.value
}
}

// mcp-oauth refuses OAUTH_PROVIDER with the authorization server off.
if authorizationServer && !present("OAUTH_PROVIDER") {
set["OAUTH_PROVIDER"] = "dex"
}
if !present("OAUTH_ENABLE_CLIENT_ID_METADATA_DOCUMENTS") {
set["OAUTH_ENABLE_CLIENT_ID_METADATA_DOCUMENTS"] = "true"
}
return set, deprecated
}

// loadOAuthSettings reads mcp-oauth's settings from the OAUTH_* variables,
// after setting those that deprecated options and skill-manager's defaults
// supply.
func loadOAuthSettings(o *serveOptions, log *slog.Logger) (oauthconfig.Settings, error) {
set, deprecated := oauthEnvironment(o, os.LookupEnv)
for _, option := range deprecated {
source := "--" + option.Flag
if option.Env != "" {
source += " (" + option.Env + ")"
}
log.Warn(source+" is deprecated and will be removed in a later release: set "+option.Replacement,
"replacement", option.Replacement)
}
for name, v := range set {
if err := os.Setenv(name, v); err != nil {
return oauthconfig.Settings{}, err
}
}
settings, err := oauthconfig.SettingsFromEnv()
if err != nil {
return oauthconfig.Settings{}, err
}
// GitHub issues no ID token, and every caller is named by one.
if settings.GitHub != nil {
return oauthconfig.Settings{}, errors.New("OAUTH_PROVIDER=github is not supported: use dex or google, which issue OpenID Connect ID tokens")
}
return settings, nil
}
Loading
Loading