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
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ MCP_REGISTRY_GITHUB_CLIENT_SECRET=0e8db54879b02c29adef51795586f3c510a9341d
# This should be a 32-byte Ed25519 seed (not the full private key). Generate a new seed with: `openssl rand -hex 32`
MCP_REGISTRY_JWT_PRIVATE_KEY=bb2c6b424005acd5df47a9e2c87f446def86dd740c888ea3efb825b23f7ef47c

# GitHub team (org/team) whose members, including those of child teams, can sign
# in as registry admins. Unset turns GitHub admin sign-in off. It doesn't turn
# off OIDC admin sign-in: set MCP_REGISTRY_OIDC_ENABLED=false for that.
MCP_REGISTRY_GITHUB_ADMIN_TEAM=
# GitHub app for admin sign-in only. Don't use the app above: tokens for
# publishing must not work for admin sign-in. It needs the callback URLs
# http://127.0.0.1:47821/callback, :47822 and :47823, read access to
# organization members, and to be installed on the team's organization. Leave
# device flow off.
MCP_REGISTRY_GITHUB_ADMIN_CLIENT_ID=
MCP_REGISTRY_GITHUB_ADMIN_CLIENT_SECRET=

# Anonymous authentication for development/testing only
# When enabled, allows anyone to get tokens for publishing to io.modelcontextprotocol.anonymous/* namespace
# This should be disabled in prod
Expand Down
2 changes: 2 additions & 0 deletions deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ Configuration keys are namespaced. Set them with `pulumi config set <key> [--sec
| `mcp-registry:provider` | Kubernetes provider (local/gcp) | No (default: local) |
| `mcp-registry:nodeMachineType` | GCP node machine type; changing it rolls nodes | No (default: e2-standard-2) |
| `mcp-registry:postgresSharedBuffers` | Registry PostgreSQL shared buffers, e.g. `512MB`; changes restart the singleton | No (PostgreSQL default) |
| `mcp-registry:githubAdminClientId` | Client ID of the GitHub app for [admin sign-in](../docs/administration/admin-operations.md#authentication). Setting it turns on GitHub admin sign-in and turns off Google's. In production it needs an `imageTag` after 1.8.21. Use a different app for each environment, and never the one for publishing. The app needs the callback URLs `http://127.0.0.1:47821/callback`, `http://127.0.0.1:47822/callback` and `http://127.0.0.1:47823/callback`, read access to organization members, and to be installed on the organization. Leave device flow off | No |
| `mcp-registry:githubAdminClientSecret` | Client secret of that app | With `githubAdminClientId` (secret) |
| `mcp-registry:githubClientId` | GitHub OAuth Client ID | Yes |
| `mcp-registry:githubClientSecret` | GitHub OAuth Client Secret | Yes (secret) |
| `mcp-registry:jwtPrivateKey` | Ed25519 seed used to sign registry JWTs | Yes (secret) |
Expand Down
48 changes: 48 additions & 0 deletions deploy/pkg/k8s/admin_login.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package k8s

import (
"errors"

corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/core/v1"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
"golang.org/x/mod/semver"
)

const (
// Managed in github.com/modelcontextprotocol/access
githubAdminTeam = "modelcontextprotocol/registry-admins"
// The last release without GitHub admin sign-in
lastGoogleOnlyRelease = "v1.8.21"
githubAdminSecretKey = "GITHUB_ADMIN_CLIENT_SECRET" //nolint:gosec // G101: the name of a key, not a credential
)

// adminLogin turns on exactly one kind of admin sign-in: GitHub if
// githubAdminClientId is set, Google otherwise. It adds the GitHub app's secret
// to secrets. It returns whether Google sign-in is on, and the settings for
// GitHub sign-in, which are empty when it is off.
func adminLogin(conf *config.Config, environment string, secrets pulumi.StringMap, secretName pulumi.StringPtrInput) (google bool, env corev1.EnvVarArray, err error) {
clientID := conf.Get("githubAdminClientId")
if clientID == "" {
return true, nil, nil
}
if clientID == conf.Get("githubClientId") {
return false, nil, errors.New("githubAdminClientId must not be the GitHub app for publishing")
}
// Older releases ignore these settings, which would leave no admin sign-in.
if version := "v" + conf.Get("imageTag"); environment == "prod" &&
(!semver.IsValid(version) || semver.Compare(version, lastGoogleOnlyRelease) <= 0) {
return false, nil, errors.New("githubAdminClientId requires an imageTag after " + lastGoogleOnlyRelease)
}
secrets[githubAdminSecretKey] = conf.RequireSecret("githubAdminClientSecret")
return false, corev1.EnvVarArray{
&corev1.EnvVarArgs{Name: pulumi.String("MCP_REGISTRY_GITHUB_ADMIN_TEAM"), Value: pulumi.String(githubAdminTeam)},
&corev1.EnvVarArgs{Name: pulumi.String("MCP_REGISTRY_GITHUB_ADMIN_CLIENT_ID"), Value: pulumi.String(clientID)},
&corev1.EnvVarArgs{
Name: pulumi.String("MCP_REGISTRY_GITHUB_ADMIN_CLIENT_SECRET"),
ValueFrom: &corev1.EnvVarSourceArgs{SecretKeyRef: &corev1.SecretKeySelectorArgs{
Name: secretName, Key: pulumi.String(githubAdminSecretKey),
}},
},
}, nil
}
59 changes: 59 additions & 0 deletions deploy/pkg/k8s/admin_login_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package k8s //nolint:testpackage // Check stack configuration without deploying.

import (
"testing"

corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/core/v1"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)

func TestAdminLogin(t *testing.T) {
for _, tc := range []struct {
name, environment, clientID, imageTag string
google, wantErr bool
}{
{"off in prod", "prod", "", "1.8.21", true, false},
{"off in staging", "staging", "", "", true, false},
{"on in staging", "staging", "admin-app", "", false, false},
{"on in prod", "prod", "admin-app", "1.8.22", false, false},
{"prod release is too old", "prod", "admin-app", "1.8.21", false, true},
{"prod release is not a version", "prod", "admin-app", "main", false, true},
{"app for publishing", "staging", "publish-app", "", false, true},
} {
t.Run(tc.name, func(t *testing.T) {
err := pulumi.RunErr(func(ctx *pulumi.Context) error {
secrets := pulumi.StringMap{}
google, env, err := adminLogin(config.New(ctx, "mcp-registry"), tc.environment, secrets, pulumi.String("secrets").ToStringPtrOutput())
if (err != nil) != tc.wantErr {
t.Fatalf("unexpected error: %v", err)
}
if tc.wantErr {
return nil
}
values := map[string]any{}
for _, v := range env {
if e := v.(*corev1.EnvVarArgs); e.Value != nil {
values[string(e.Name.(pulumi.String))] = e.Value
}
}
wantTeam, wantEnv, wantSecrets := any(nil), 0, 0
if !tc.google {
wantTeam, wantEnv, wantSecrets = pulumi.String(githubAdminTeam), 3, 1
}
if google != tc.google || values["MCP_REGISTRY_GITHUB_ADMIN_TEAM"] != wantTeam || len(env) != wantEnv || len(secrets) != wantSecrets {
t.Errorf("unexpected settings: google %v, %v, %d secrets", google, values, len(secrets))
}
return nil
}, pulumi.WithMocks("admin-login-test", "staging", ownershipMonitor{t}), func(info *pulumi.RunInfo) {
info.Config = map[string]string{
"mcp-registry:githubClientId": "publish-app", "mcp-registry:githubAdminClientId": tc.clientID,
"mcp-registry:githubAdminClientSecret": "test", "mcp-registry:imageTag": tc.imageTag,
}
})
if err != nil {
t.Fatal(err)
}
})
}
}
22 changes: 14 additions & 8 deletions deploy/pkg/k8s/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ func DeployMCPRegistry(ctx *pulumi.Context, cluster *providers.ProviderInfo, env
registryCPURequest = request
}

secrets := pulumi.StringMap{
"GITHUB_CLIENT_SECRET": conf.RequireSecret("githubClientSecret"),
"JWT_PRIVATE_KEY": conf.RequireSecret("jwtPrivateKey"),
}
googleAdminLogin, adminEnv, err := adminLogin(conf, environment, secrets, pulumi.String("mcp-registry-secrets"))
if err != nil {
return nil, err
}

// Create Secret with sensitive configuration
secret, err := corev1.NewSecret(ctx, "mcp-registry-secrets", &corev1.SecretArgs{
Metadata: &metav1.ObjectMetaArgs{
Expand All @@ -99,11 +108,8 @@ func DeployMCPRegistry(ctx *pulumi.Context, cluster *providers.ProviderInfo, env
"environment": pulumi.String(environment),
},
},
StringData: pulumi.StringMap{
"GITHUB_CLIENT_SECRET": conf.RequireSecret("githubClientSecret"),
"JWT_PRIVATE_KEY": conf.RequireSecret("jwtPrivateKey"),
},
Type: pulumi.String("Opaque"),
StringData: secrets,
Type: pulumi.String("Opaque"),
}, pulumi.Provider(cluster.Provider))
if err != nil {
return nil, err
Expand Down Expand Up @@ -268,10 +274,10 @@ func DeployMCPRegistry(ctx *pulumi.Context, cluster *providers.ProviderInfo, env
},
},
},
// Google Cloud Identity OIDC for admin access
// Google Cloud Identity OIDC for admin access, unless adminEnv turns on GitHub
&corev1.EnvVarArgs{
Name: pulumi.String("MCP_REGISTRY_OIDC_ENABLED"),
Value: pulumi.String("true"),
Value: pulumi.String(strconv.FormatBool(googleAdminLogin)),
},
&corev1.EnvVarArgs{
Name: pulumi.String("MCP_REGISTRY_OIDC_ISSUER"),
Expand Down Expand Up @@ -302,7 +308,7 @@ func DeployMCPRegistry(ctx *pulumi.Context, cluster *providers.ProviderInfo, env
return "https://" + environment + ".registry.modelcontextprotocol.io"
}()),
},
}, poolEnv...),
}, append(adminEnv, poolEnv...)...),
// StartupProbe protects the DB-retry budget in cmd/registry/main.go:
// 30 × 5s = 150s allowed before liveness/readiness take over, which
// covers the worst-case retry budget (8 attempts × 10s + ~40s sleep).
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ services:
- MCP_REGISTRY_DATABASE_URL=${MCP_REGISTRY_DATABASE_URL:-postgres://mcpregistry:mcpregistry@postgres:5432/mcp-registry}
- MCP_REGISTRY_GITHUB_CLIENT_ID=${MCP_REGISTRY_GITHUB_CLIENT_ID:-Iv23licy3GSiM9Km5jtd}
- MCP_REGISTRY_GITHUB_CLIENT_SECRET=${MCP_REGISTRY_GITHUB_CLIENT_SECRET:-0e8db54879b02c29adef51795586f3c510a9341d}
- MCP_REGISTRY_GITHUB_ADMIN_TEAM=${MCP_REGISTRY_GITHUB_ADMIN_TEAM:-}
- MCP_REGISTRY_GITHUB_ADMIN_CLIENT_ID=${MCP_REGISTRY_GITHUB_ADMIN_CLIENT_ID:-}
- MCP_REGISTRY_GITHUB_ADMIN_CLIENT_SECRET=${MCP_REGISTRY_GITHUB_ADMIN_CLIENT_SECRET:-}
- MCP_REGISTRY_JWT_PRIVATE_KEY=${MCP_REGISTRY_JWT_PRIVATE_KEY:-8103179d8ef955f6d3de6d6217224a909ec4060529dfeb1d4ca5a994537658cd}
- MCP_REGISTRY_ENABLE_ANONYMOUS_AUTH=${MCP_REGISTRY_ENABLE_ANONYMOUS_AUTH:-true}
- MCP_REGISTRY_SEED_FROM=${MCP_REGISTRY_SEED_FROM:-https://registry.modelcontextprotocol.io/v0/servers?search=domdomegg}
Expand Down
10 changes: 7 additions & 3 deletions docs/administration/admin-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ This is a brief guide for admins and moderators managing content on the registry

## Prerequisites

- Admin account with @modelcontextprotocol.io email
- If you are a maintainer and would like an account, ask in the Discord
- `registry-admins` role in the [access repository](https://github.com/modelcontextprotocol/access#add-or-remove-a-registry-admin), and an @modelcontextprotocol.io account for registries that still use Google sign-in
- If you are a maintainer and need access, ask in the Discord
- `gcloud` CLI installed and configured
- `curl` and `jq` installed
- `curl`, `jq` and Python 3 installed
- `kubectl` installed with `gke-gcloud-auth-plugin` (for database access)

A takedown made with global registry edit permission places a hold on the affected versions. A moderator can also place a hold on a previously withdrawn version by setting its status to `deleted` again. Restoring the version clears the hold. A publisher's bulk status change fails in full if any targeted version is held. New versions are evaluated separately.
Expand All @@ -19,6 +19,10 @@ A takedown made with global registry edit permission places a hold on the affect
./tools/admin/auth.sh
```

Where the stack file in `deploy/` has a `githubAdminClientId`, the script signs you in with GitHub in your browser, and the registry checks that you are in the `registry-admins` team. Otherwise it uses `gcloud`. Run it from an up-to-date checkout.

Set `REGISTRY_URL` to use another registry, such as staging. For one that isn't hosted by us, set `GITHUB_ADMIN_CLIENT_ID` to its own GitHub app, and only do this for a registry you trust, because it receives your sign-in code. Without that setting, the script uses `gcloud`, and only for a registry on this computer. Run the script on the computer where your browser is, and finish one sign-in before you start another.

## Edit a Specific Server Version

Use this when you need to modify details of a specific version (e.g., fix description, update status, modify packages).
Expand Down
1 change: 1 addition & 0 deletions docs/administration/maintainer-onboarding.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ When onboarding a new maintainer, complete the following steps:
### 1. Access Repository (GitHub, Google Workspace)

- [ ] Open a PR on the [modelcontextprotocol/access](https://github.com/modelcontextprotocol/access) repository
- [ ] For registry admins, include the `registry-admins` role in that PR

### 2. MAINTAINERS.md

Expand Down
46 changes: 15 additions & 31 deletions docs/design/tech-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,40 +184,24 @@ sequenceDiagram
CLI-->>User: Success!
```

### 4. Admin OIDC Authentication Flow
### 4. Admin Authentication Flow

For registry administration, users with @modelcontextprotocol.io Google Cloud Identity accounts can authenticate using OIDC:
Where GitHub admin sign-in is configured, admins use the authorization code flow with PKCE in their browser. The code returns to `127.0.0.1` on their computer, and the registry exchanges it using its GitHub app for admins. There is no device flow, and the endpoint doesn't accept GitHub tokens, so a publishing token never grants admin permissions. The user must be an active member of the configured team or its child teams. Hosted registries without an admin app use Google sign-in through `/auth/oidc` instead.

```mermaid
sequenceDiagram
participant Admin as Admin User
participant CLI as Admin CLI
participant GCP as Google Cloud Identity
participant Admin as Admin's browser
participant CLI as auth.sh
participant GH as GitHub
participant API as Registry API

Admin->>CLI: Request admin token
CLI->>GCP: gcloud auth print-identity-token --audiences=mcp-registry
GCP-->>CLI: ID Token (with hd: "modelcontextprotocol.io")
CLI->>API: POST /v0.1/auth/oidc {"oidc_token": "eyJ..."}
API->>GCP: Verify token signature (JWKS)
API->>API: Validate claims (issuer, audience, hd)
API->>API: Grant admin permissions (edit: *, publish: *)
API-->>CLI: Registry JWT Token
CLI->>API: POST /admin/* (with Registry JWT)
API->>API: Validate JWT + permissions
API-->>CLI: Admin operation success
```

**Usage:**
```bash
# Get Google Cloud Identity token
ID_TOKEN=$(gcloud auth print-identity-token)

# Exchange for Registry JWT token
REGISTRY_TOKEN=$(curl -X POST /v0.1/auth/oidc \
-H "Content-Type: application/json" \
-d '{"oidc_token": "'$ID_TOKEN'"}' | jq -r .registry_token)

# Use for admin operations
curl -H "Authorization: Bearer $REGISTRY_TOKEN" /v0.1/...
```
CLI->>Admin: Open GitHub with state and PKCE challenge
Admin->>GH: Sign in and authorize
GH-->>CLI: Code, through 127.0.0.1
CLI->>CLI: Check state
CLI->>API: POST /v0/auth/github-admin (code and PKCE verifier)
API->>GH: Exchange the code, with the app's secret
API->>GH: Check that the user is in the admin team
API->>GH: Revoke the user's authorization and token
API-->>CLI: Registry JWT (5 minutes)
```
3 changes: 2 additions & 1 deletion docs/reference/api/official-registry-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ The `GET /v0.1/servers/{serverName}/versions` endpoint returns all versions of a
- POST `/v0.1/auth/dns` - Exchange signed DNS challenge for auth token
- POST `/v0.1/auth/http` - Exchange signed HTTP challenge for auth token
- POST `/v0.1/auth/github-at` - Exchange GitHub access token for auth token
- POST `/v0.1/auth/github-admin` - Exchange GitHub authorization code and PKCE verifier for admin auth token (for admins, where configured)
- POST `/v0.1/auth/github-oidc` - Exchange GitHub OIDC token for auth token
- POST `/v0.1/auth/oidc` - Exchange Google OIDC token for auth token (for admins)
- POST `/v0.1/auth/oidc` - Exchange Google OIDC token for auth token (for admins, where configured)

#### Status endpoints

Expand Down
2 changes: 1 addition & 1 deletion internal/api/handlers/v0/auth/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func (h *CoreAuthHandler) ExchangeToken(
return nil, fmt.Errorf("no MCP public key found in HTTP response")
case auth.MethodDNS:
return nil, fmt.Errorf("no MCP public key found in DNS TXT records")
case auth.MethodGitHubAT, auth.MethodGitHubOIDC, auth.MethodOIDC, auth.MethodNone:
case auth.MethodGitHubAT, auth.MethodGitHubAdmin, auth.MethodGitHubOIDC, auth.MethodOIDC, auth.MethodNone:
default:
return nil, fmt.Errorf("no MCP public key found using %s authentication", authMethod)
}
Expand Down
Loading
Loading