From d70ce3855936cbe80cffe3aed6d8e42a75f584ce Mon Sep 17 00:00:00 2001 From: Ethan <39577870+ethanndickson@users.noreply.github.com> Date: Tue, 3 Nov 2026 12:39:30 +1100 Subject: [PATCH] feat: record the OAuth2 client registration method of MCP server configs (#31558) Relates to CODAGT-779 Currently we can't tell whether the OAuth2 client of an MCP server config was entered by an admin, or registered by Coder with Dynamic Client Registration (RFC 7591). The next PR in the stack needs to know this, so it can register a new client when a config is updated. This PR adds `mcp_server_configs.oauth2_client_registration` (`manual` or `dynamic`) and returns it to admins on the API. Create stores `dynamic` when it registers the client, and `manual` otherwise. An update resets it to `manual` when it switches away from the `oauth2` auth type, or when it changes the client ID, secret, auth URL or token URL of a `dynamic` config, since the admin has replaced Coder's client. Existing rows default to `manual`, as there's nothing in the data that tells us which clients came from Dynamic Client Registration. --- coderd/apidoc/docs.go | 14 ++ coderd/apidoc/swagger.json | 11 + coderd/database/check_constraint.go | 1 + coderd/database/dbgen/dbgen.go | 71 +++--- coderd/database/dump.sql | 2 + ...server_oauth2_client_registration.down.sql | 1 + ...p_server_oauth2_client_registration.up.sql | 4 + coderd/database/modelqueries.go | 1 + coderd/database/models.go | 75 ++++--- coderd/database/queries.sql.go | 210 ++++++++++-------- coderd/database/queries/mcpserverconfigs.sql | 3 + coderd/database/sqlc.yaml | 1 + coderd/mcp.go | 147 ++++++------ coderd/mcp_test.go | 25 +++ .../x/chatd/turn_environment_internal_test.go | 27 +-- codersdk/mcp.go | 16 ++ docs/admin/security/audit-logs.md | 1 + docs/reference/api/schemas.md | 80 ++++--- enterprise/audit/table.go | 1 + enterprise/dbcrypt/dbcrypt_internal_test.go | 35 +-- site/src/api/typesGenerated.ts | 7 + 21 files changed, 440 insertions(+), 293 deletions(-) create mode 100644 coderd/database/migrations/000639_mcp_server_oauth2_client_registration.down.sql create mode 100644 coderd/database/migrations/000639_mcp_server_oauth2_client_registration.up.sql diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index 2637e23f09f..abe2a77a8c5 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -27616,6 +27616,9 @@ const docTemplate = `{ "description": "OAuth2 fields (only populated for admins).", "type": "string" }, + "oauth2_client_registration": { + "$ref": "#/definitions/codersdk.MCPServerOAuth2ClientRegistration" + }, "oauth2_resource": { "type": "string" }, @@ -27777,6 +27780,17 @@ const docTemplate = `{ } } }, + "codersdk.MCPServerOAuth2ClientRegistration": { + "type": "string", + "enum": [ + "manual", + "dynamic" + ], + "x-enum-varnames": [ + "MCPServerOAuth2ClientRegistrationManual", + "MCPServerOAuth2ClientRegistrationDynamic" + ] + }, "codersdk.MCPServerOAuth2DisconnectResponse": { "type": "object", "properties": { diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 7f84efbe5ee..ef438e715c9 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -25240,6 +25240,9 @@ "description": "OAuth2 fields (only populated for admins).", "type": "string" }, + "oauth2_client_registration": { + "$ref": "#/definitions/codersdk.MCPServerOAuth2ClientRegistration" + }, "oauth2_resource": { "type": "string" }, @@ -25391,6 +25394,14 @@ } } }, + "codersdk.MCPServerOAuth2ClientRegistration": { + "type": "string", + "enum": ["manual", "dynamic"], + "x-enum-varnames": [ + "MCPServerOAuth2ClientRegistrationManual", + "MCPServerOAuth2ClientRegistrationDynamic" + ] + }, "codersdk.MCPServerOAuth2DisconnectResponse": { "type": "object", "properties": { diff --git a/coderd/database/check_constraint.go b/coderd/database/check_constraint.go index 6d30504c57a..91127ea1765 100644 --- a/coderd/database/check_constraint.go +++ b/coderd/database/check_constraint.go @@ -67,6 +67,7 @@ const ( CheckMcpServerConfigsAuthTypeCheck CheckConstraint = "mcp_server_configs_auth_type_check" // mcp_server_configs CheckMcpServerConfigsAvailabilityCheck CheckConstraint = "mcp_server_configs_availability_check" // mcp_server_configs CheckMcpServerConfigsGroupAclIsObject CheckConstraint = "mcp_server_configs_group_acl_is_object" // mcp_server_configs + CheckMcpServerConfigsOauth2ClientRegistrationCheck CheckConstraint = "mcp_server_configs_oauth2_client_registration_check" // mcp_server_configs CheckMcpServerConfigsTransportCheck CheckConstraint = "mcp_server_configs_transport_check" // mcp_server_configs CheckMcpServerConfigsUserAclIsObject CheckConstraint = "mcp_server_configs_user_acl_is_object" // mcp_server_configs CheckOauth2ProviderAppCodesScopeNotEmpty CheckConstraint = "oauth2_provider_app_codes_scope_not_empty" // oauth2_provider_app_codes diff --git a/coderd/database/dbgen/dbgen.go b/coderd/database/dbgen/dbgen.go index 8a8b799e1ff..15a3669cbfb 100644 --- a/coderd/database/dbgen/dbgen.go +++ b/coderd/database/dbgen/dbgen.go @@ -409,41 +409,42 @@ func MCPServerConfig(t testing.TB, db database.Store, seed database.MCPServerCon } cfg, err := db.InsertMCPServerConfig(genCtx, database.InsertMCPServerConfigParams{ - ID: takeFirst(seed.ID, uuid.New()), - OrganizationID: organizationID, - DisplayName: takeFirst(seed.DisplayName, "Test MCP Server"), - Slug: takeFirst(seed.Slug, testutil.GetRandomName(t)), - Description: seed.Description, - IconURL: seed.IconURL, - Transport: takeFirst(seed.Transport, "streamable_http"), - Url: takeFirst(seed.Url, "https://mcp.example.com"), - AuthType: takeFirst(seed.AuthType, "none"), - OAuth2ClientID: seed.OAuth2ClientID, - OAuth2ClientSecret: seed.OAuth2ClientSecret, - OAuth2ClientSecretKeyID: seed.OAuth2ClientSecretKeyID, - OAuth2AuthURL: seed.OAuth2AuthURL, - OAuth2TokenURL: seed.OAuth2TokenURL, - OAuth2RevocationURL: seed.OAuth2RevocationURL, - OAuth2Resource: seed.OAuth2Resource, - OAuth2Scopes: seed.OAuth2Scopes, - APIKeyHeader: seed.APIKeyHeader, - APIKeyValue: seed.APIKeyValue, - APIKeyValueKeyID: seed.APIKeyValueKeyID, - CustomHeaders: seed.CustomHeaders, - CustomHeadersKeyID: seed.CustomHeadersKeyID, - SigningSecret: seed.SigningSecret, - SigningSecretKeyID: seed.SigningSecretKeyID, - ToolAllowList: takeFirstSlice(seed.ToolAllowList, []string{}), - ToolDenyList: takeFirstSlice(seed.ToolDenyList, []string{}), - Availability: takeFirst(seed.Availability, "default_off"), - Enabled: takeFirst(seed.Enabled, true), - ModelIntent: seed.ModelIntent, - AllowInPlanMode: seed.AllowInPlanMode, - ForwardCoderHeaders: seed.ForwardCoderHeaders, - GroupACL: groupACL, - UserACL: userACL, - CreatedBy: createdBy, - UpdatedBy: updatedBy, + ID: takeFirst(seed.ID, uuid.New()), + OrganizationID: organizationID, + DisplayName: takeFirst(seed.DisplayName, "Test MCP Server"), + Slug: takeFirst(seed.Slug, testutil.GetRandomName(t)), + Description: seed.Description, + IconURL: seed.IconURL, + Transport: takeFirst(seed.Transport, "streamable_http"), + Url: takeFirst(seed.Url, "https://mcp.example.com"), + AuthType: takeFirst(seed.AuthType, "none"), + OAuth2ClientID: seed.OAuth2ClientID, + OAuth2ClientSecret: seed.OAuth2ClientSecret, + OAuth2ClientSecretKeyID: seed.OAuth2ClientSecretKeyID, + OAuth2AuthURL: seed.OAuth2AuthURL, + OAuth2TokenURL: seed.OAuth2TokenURL, + OAuth2RevocationURL: seed.OAuth2RevocationURL, + OAuth2Resource: seed.OAuth2Resource, + OAuth2Scopes: seed.OAuth2Scopes, + OAuth2ClientRegistration: takeFirst(seed.OAuth2ClientRegistration, "manual"), + APIKeyHeader: seed.APIKeyHeader, + APIKeyValue: seed.APIKeyValue, + APIKeyValueKeyID: seed.APIKeyValueKeyID, + CustomHeaders: seed.CustomHeaders, + CustomHeadersKeyID: seed.CustomHeadersKeyID, + SigningSecret: seed.SigningSecret, + SigningSecretKeyID: seed.SigningSecretKeyID, + ToolAllowList: takeFirstSlice(seed.ToolAllowList, []string{}), + ToolDenyList: takeFirstSlice(seed.ToolDenyList, []string{}), + Availability: takeFirst(seed.Availability, "default_off"), + Enabled: takeFirst(seed.Enabled, true), + ModelIntent: seed.ModelIntent, + AllowInPlanMode: seed.AllowInPlanMode, + ForwardCoderHeaders: seed.ForwardCoderHeaders, + GroupACL: groupACL, + UserACL: userACL, + CreatedBy: createdBy, + UpdatedBy: updatedBy, }) require.NoError(t, err, "insert MCP server config") return cfg diff --git a/coderd/database/dump.sql b/coderd/database/dump.sql index edf96b35b29..049722c18d5 100644 --- a/coderd/database/dump.sql +++ b/coderd/database/dump.sql @@ -2902,9 +2902,11 @@ CREATE TABLE mcp_server_configs ( signing_secret text DEFAULT ''::text NOT NULL, signing_secret_key_id text, oauth2_resource text DEFAULT ''::text NOT NULL, + oauth2_client_registration text DEFAULT 'manual'::text NOT NULL, CONSTRAINT mcp_server_configs_auth_type_check CHECK ((auth_type = ANY (ARRAY['none'::text, 'oauth2'::text, 'api_key'::text, 'custom_headers'::text, 'user_oidc'::text]))), CONSTRAINT mcp_server_configs_availability_check CHECK ((availability = ANY (ARRAY['force_on'::text, 'default_on'::text, 'default_off'::text]))), CONSTRAINT mcp_server_configs_group_acl_is_object CHECK ((jsonb_typeof(group_acl) = 'object'::text)), + CONSTRAINT mcp_server_configs_oauth2_client_registration_check CHECK ((oauth2_client_registration = ANY (ARRAY['manual'::text, 'dynamic'::text]))), CONSTRAINT mcp_server_configs_transport_check CHECK ((transport = ANY (ARRAY['streamable_http'::text, 'sse'::text]))), CONSTRAINT mcp_server_configs_user_acl_is_object CHECK ((jsonb_typeof(user_acl) = 'object'::text)) ); diff --git a/coderd/database/migrations/000639_mcp_server_oauth2_client_registration.down.sql b/coderd/database/migrations/000639_mcp_server_oauth2_client_registration.down.sql new file mode 100644 index 00000000000..42b576022af --- /dev/null +++ b/coderd/database/migrations/000639_mcp_server_oauth2_client_registration.down.sql @@ -0,0 +1 @@ +ALTER TABLE mcp_server_configs DROP COLUMN oauth2_client_registration; diff --git a/coderd/database/migrations/000639_mcp_server_oauth2_client_registration.up.sql b/coderd/database/migrations/000639_mcp_server_oauth2_client_registration.up.sql new file mode 100644 index 00000000000..534f9dd1553 --- /dev/null +++ b/coderd/database/migrations/000639_mcp_server_oauth2_client_registration.up.sql @@ -0,0 +1,4 @@ +ALTER TABLE mcp_server_configs + ADD COLUMN oauth2_client_registration text NOT NULL DEFAULT 'manual' + CONSTRAINT mcp_server_configs_oauth2_client_registration_check + CHECK (oauth2_client_registration IN ('manual', 'dynamic')); diff --git a/coderd/database/modelqueries.go b/coderd/database/modelqueries.go index 3a00653835a..f5b4f968675 100644 --- a/coderd/database/modelqueries.go +++ b/coderd/database/modelqueries.go @@ -1348,6 +1348,7 @@ func (q *sqlQuerier) GetAuthorizedMCPServerConfigs(ctx context.Context, organiza &i.SigningSecret, &i.SigningSecretKeyID, &i.OAuth2Resource, + &i.OAuth2ClientRegistration, ); err != nil { return nil, err } diff --git a/coderd/database/models.go b/coderd/database/models.go index 1155894b5ad..54a636523f6 100644 --- a/coderd/database/models.go +++ b/coderd/database/models.go @@ -5903,43 +5903,44 @@ type License struct { } type MCPServerConfig struct { - ID uuid.UUID `db:"id" json:"id"` - DisplayName string `db:"display_name" json:"display_name"` - Slug string `db:"slug" json:"slug"` - Description string `db:"description" json:"description"` - IconURL string `db:"icon_url" json:"icon_url"` - Transport string `db:"transport" json:"transport"` - Url string `db:"url" json:"url"` - AuthType string `db:"auth_type" json:"auth_type"` - OAuth2ClientID string `db:"oauth2_client_id" json:"oauth2_client_id"` - OAuth2ClientSecret string `db:"oauth2_client_secret" json:"oauth2_client_secret"` - OAuth2ClientSecretKeyID sql.NullString `db:"oauth2_client_secret_key_id" json:"oauth2_client_secret_key_id"` - OAuth2AuthURL string `db:"oauth2_auth_url" json:"oauth2_auth_url"` - OAuth2TokenURL string `db:"oauth2_token_url" json:"oauth2_token_url"` - OAuth2Scopes string `db:"oauth2_scopes" json:"oauth2_scopes"` - APIKeyHeader string `db:"api_key_header" json:"api_key_header"` - APIKeyValue string `db:"api_key_value" json:"api_key_value"` - APIKeyValueKeyID sql.NullString `db:"api_key_value_key_id" json:"api_key_value_key_id"` - CustomHeaders string `db:"custom_headers" json:"custom_headers"` - CustomHeadersKeyID sql.NullString `db:"custom_headers_key_id" json:"custom_headers_key_id"` - ToolAllowList []string `db:"tool_allow_list" json:"tool_allow_list"` - ToolDenyList []string `db:"tool_deny_list" json:"tool_deny_list"` - Availability string `db:"availability" json:"availability"` - Enabled bool `db:"enabled" json:"enabled"` - CreatedBy uuid.NullUUID `db:"created_by" json:"created_by"` - UpdatedBy uuid.NullUUID `db:"updated_by" json:"updated_by"` - CreatedAt time.Time `db:"created_at" json:"created_at"` - UpdatedAt time.Time `db:"updated_at" json:"updated_at"` - ModelIntent bool `db:"model_intent" json:"model_intent"` - AllowInPlanMode bool `db:"allow_in_plan_mode" json:"allow_in_plan_mode"` - ForwardCoderHeaders bool `db:"forward_coder_headers" json:"forward_coder_headers"` - OAuth2RevocationURL string `db:"oauth2_revocation_url" json:"oauth2_revocation_url"` - OrganizationID uuid.UUID `db:"organization_id" json:"organization_id"` - GroupACL ChatACL `db:"group_acl" json:"group_acl"` - UserACL ChatACL `db:"user_acl" json:"user_acl"` - SigningSecret string `db:"signing_secret" json:"signing_secret"` - SigningSecretKeyID sql.NullString `db:"signing_secret_key_id" json:"signing_secret_key_id"` - OAuth2Resource string `db:"oauth2_resource" json:"oauth2_resource"` + ID uuid.UUID `db:"id" json:"id"` + DisplayName string `db:"display_name" json:"display_name"` + Slug string `db:"slug" json:"slug"` + Description string `db:"description" json:"description"` + IconURL string `db:"icon_url" json:"icon_url"` + Transport string `db:"transport" json:"transport"` + Url string `db:"url" json:"url"` + AuthType string `db:"auth_type" json:"auth_type"` + OAuth2ClientID string `db:"oauth2_client_id" json:"oauth2_client_id"` + OAuth2ClientSecret string `db:"oauth2_client_secret" json:"oauth2_client_secret"` + OAuth2ClientSecretKeyID sql.NullString `db:"oauth2_client_secret_key_id" json:"oauth2_client_secret_key_id"` + OAuth2AuthURL string `db:"oauth2_auth_url" json:"oauth2_auth_url"` + OAuth2TokenURL string `db:"oauth2_token_url" json:"oauth2_token_url"` + OAuth2Scopes string `db:"oauth2_scopes" json:"oauth2_scopes"` + APIKeyHeader string `db:"api_key_header" json:"api_key_header"` + APIKeyValue string `db:"api_key_value" json:"api_key_value"` + APIKeyValueKeyID sql.NullString `db:"api_key_value_key_id" json:"api_key_value_key_id"` + CustomHeaders string `db:"custom_headers" json:"custom_headers"` + CustomHeadersKeyID sql.NullString `db:"custom_headers_key_id" json:"custom_headers_key_id"` + ToolAllowList []string `db:"tool_allow_list" json:"tool_allow_list"` + ToolDenyList []string `db:"tool_deny_list" json:"tool_deny_list"` + Availability string `db:"availability" json:"availability"` + Enabled bool `db:"enabled" json:"enabled"` + CreatedBy uuid.NullUUID `db:"created_by" json:"created_by"` + UpdatedBy uuid.NullUUID `db:"updated_by" json:"updated_by"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + UpdatedAt time.Time `db:"updated_at" json:"updated_at"` + ModelIntent bool `db:"model_intent" json:"model_intent"` + AllowInPlanMode bool `db:"allow_in_plan_mode" json:"allow_in_plan_mode"` + ForwardCoderHeaders bool `db:"forward_coder_headers" json:"forward_coder_headers"` + OAuth2RevocationURL string `db:"oauth2_revocation_url" json:"oauth2_revocation_url"` + OrganizationID uuid.UUID `db:"organization_id" json:"organization_id"` + GroupACL ChatACL `db:"group_acl" json:"group_acl"` + UserACL ChatACL `db:"user_acl" json:"user_acl"` + SigningSecret string `db:"signing_secret" json:"signing_secret"` + SigningSecretKeyID sql.NullString `db:"signing_secret_key_id" json:"signing_secret_key_id"` + OAuth2Resource string `db:"oauth2_resource" json:"oauth2_resource"` + OAuth2ClientRegistration string `db:"oauth2_client_registration" json:"oauth2_client_registration"` } type MCPServerUserToken struct { diff --git a/coderd/database/queries.sql.go b/coderd/database/queries.sql.go index e2885d00444..83a3ad282f5 100644 --- a/coderd/database/queries.sql.go +++ b/coderd/database/queries.sql.go @@ -20048,7 +20048,7 @@ func (q *sqlQuerier) DeleteMCPServerUserTokensByConfigID(ctx context.Context, mc const getEnabledMCPServerConfigsByOrganization = `-- name: GetEnabledMCPServerConfigsByOrganization :many SELECT - id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource + id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource, oauth2_client_registration FROM mcp_server_configs WHERE @@ -20105,6 +20105,7 @@ func (q *sqlQuerier) GetEnabledMCPServerConfigsByOrganization(ctx context.Contex &i.SigningSecret, &i.SigningSecretKeyID, &i.OAuth2Resource, + &i.OAuth2ClientRegistration, ); err != nil { return nil, err } @@ -20121,7 +20122,7 @@ func (q *sqlQuerier) GetEnabledMCPServerConfigsByOrganization(ctx context.Contex const getEnabledMCPServerConfigsByOrganizationAndIDs = `-- name: GetEnabledMCPServerConfigsByOrganizationAndIDs :many SELECT - id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource + id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource, oauth2_client_registration FROM mcp_server_configs WHERE @@ -20184,6 +20185,7 @@ func (q *sqlQuerier) GetEnabledMCPServerConfigsByOrganizationAndIDs(ctx context. &i.SigningSecret, &i.SigningSecretKeyID, &i.OAuth2Resource, + &i.OAuth2ClientRegistration, ); err != nil { return nil, err } @@ -20200,7 +20202,7 @@ func (q *sqlQuerier) GetEnabledMCPServerConfigsByOrganizationAndIDs(ctx context. const getForcedMCPServerConfigsByOrganization = `-- name: GetForcedMCPServerConfigsByOrganization :many SELECT - id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource + id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource, oauth2_client_registration FROM mcp_server_configs WHERE @@ -20258,6 +20260,7 @@ func (q *sqlQuerier) GetForcedMCPServerConfigsByOrganization(ctx context.Context &i.SigningSecret, &i.SigningSecretKeyID, &i.OAuth2Resource, + &i.OAuth2ClientRegistration, ); err != nil { return nil, err } @@ -20274,7 +20277,7 @@ func (q *sqlQuerier) GetForcedMCPServerConfigsByOrganization(ctx context.Context const getMCPServerConfigByID = `-- name: GetMCPServerConfigByID :one SELECT - id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource + id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource, oauth2_client_registration FROM mcp_server_configs WHERE @@ -20322,13 +20325,14 @@ func (q *sqlQuerier) GetMCPServerConfigByID(ctx context.Context, id uuid.UUID) ( &i.SigningSecret, &i.SigningSecretKeyID, &i.OAuth2Resource, + &i.OAuth2ClientRegistration, ) return i, err } const getMCPServerConfigByIDForUpdate = `-- name: GetMCPServerConfigByIDForUpdate :one SELECT - id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource + id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource, oauth2_client_registration FROM mcp_server_configs WHERE @@ -20377,13 +20381,14 @@ func (q *sqlQuerier) GetMCPServerConfigByIDForUpdate(ctx context.Context, id uui &i.SigningSecret, &i.SigningSecretKeyID, &i.OAuth2Resource, + &i.OAuth2ClientRegistration, ) return i, err } const getMCPServerConfigByOrganizationAndSlug = `-- name: GetMCPServerConfigByOrganizationAndSlug :one SELECT - id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource + id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource, oauth2_client_registration FROM mcp_server_configs WHERE @@ -20437,13 +20442,14 @@ func (q *sqlQuerier) GetMCPServerConfigByOrganizationAndSlug(ctx context.Context &i.SigningSecret, &i.SigningSecretKeyID, &i.OAuth2Resource, + &i.OAuth2ClientRegistration, ) return i, err } const getMCPServerConfigsByOrganization = `-- name: GetMCPServerConfigsByOrganization :many SELECT - id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource + id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource, oauth2_client_registration FROM mcp_server_configs WHERE @@ -20501,6 +20507,7 @@ func (q *sqlQuerier) GetMCPServerConfigsByOrganization(ctx context.Context, orga &i.SigningSecret, &i.SigningSecretKeyID, &i.OAuth2Resource, + &i.OAuth2ClientRegistration, ); err != nil { return nil, err } @@ -20643,6 +20650,7 @@ INSERT INTO mcp_server_configs ( oauth2_revocation_url, oauth2_resource, oauth2_scopes, + oauth2_client_registration, api_key_header, api_key_value, api_key_value_key_id, @@ -20686,58 +20694,60 @@ INSERT INTO mcp_server_configs ( $22::text, $23::text, $24::text, - $25::text[], + $25::text, $26::text[], - $27::text, - $28::boolean, + $27::text[], + $28::text, $29::boolean, $30::boolean, $31::boolean, - $32, + $32::boolean, $33, - $34::uuid, - $35::uuid + $34, + $35::uuid, + $36::uuid ) RETURNING - id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource + id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource, oauth2_client_registration ` type InsertMCPServerConfigParams struct { - ID uuid.UUID `db:"id" json:"id"` - OrganizationID uuid.UUID `db:"organization_id" json:"organization_id"` - DisplayName string `db:"display_name" json:"display_name"` - Slug string `db:"slug" json:"slug"` - Description string `db:"description" json:"description"` - IconURL string `db:"icon_url" json:"icon_url"` - Transport string `db:"transport" json:"transport"` - Url string `db:"url" json:"url"` - AuthType string `db:"auth_type" json:"auth_type"` - OAuth2ClientID string `db:"oauth2_client_id" json:"oauth2_client_id"` - OAuth2ClientSecret string `db:"oauth2_client_secret" json:"oauth2_client_secret"` - OAuth2ClientSecretKeyID sql.NullString `db:"oauth2_client_secret_key_id" json:"oauth2_client_secret_key_id"` - OAuth2AuthURL string `db:"oauth2_auth_url" json:"oauth2_auth_url"` - OAuth2TokenURL string `db:"oauth2_token_url" json:"oauth2_token_url"` - OAuth2RevocationURL string `db:"oauth2_revocation_url" json:"oauth2_revocation_url"` - OAuth2Resource string `db:"oauth2_resource" json:"oauth2_resource"` - OAuth2Scopes string `db:"oauth2_scopes" json:"oauth2_scopes"` - APIKeyHeader string `db:"api_key_header" json:"api_key_header"` - APIKeyValue string `db:"api_key_value" json:"api_key_value"` - APIKeyValueKeyID sql.NullString `db:"api_key_value_key_id" json:"api_key_value_key_id"` - CustomHeaders string `db:"custom_headers" json:"custom_headers"` - CustomHeadersKeyID sql.NullString `db:"custom_headers_key_id" json:"custom_headers_key_id"` - SigningSecret string `db:"signing_secret" json:"signing_secret"` - SigningSecretKeyID sql.NullString `db:"signing_secret_key_id" json:"signing_secret_key_id"` - ToolAllowList []string `db:"tool_allow_list" json:"tool_allow_list"` - ToolDenyList []string `db:"tool_deny_list" json:"tool_deny_list"` - Availability string `db:"availability" json:"availability"` - Enabled bool `db:"enabled" json:"enabled"` - ModelIntent bool `db:"model_intent" json:"model_intent"` - AllowInPlanMode bool `db:"allow_in_plan_mode" json:"allow_in_plan_mode"` - ForwardCoderHeaders bool `db:"forward_coder_headers" json:"forward_coder_headers"` - GroupACL ChatACL `db:"group_acl" json:"group_acl"` - UserACL ChatACL `db:"user_acl" json:"user_acl"` - CreatedBy uuid.UUID `db:"created_by" json:"created_by"` - UpdatedBy uuid.UUID `db:"updated_by" json:"updated_by"` + ID uuid.UUID `db:"id" json:"id"` + OrganizationID uuid.UUID `db:"organization_id" json:"organization_id"` + DisplayName string `db:"display_name" json:"display_name"` + Slug string `db:"slug" json:"slug"` + Description string `db:"description" json:"description"` + IconURL string `db:"icon_url" json:"icon_url"` + Transport string `db:"transport" json:"transport"` + Url string `db:"url" json:"url"` + AuthType string `db:"auth_type" json:"auth_type"` + OAuth2ClientID string `db:"oauth2_client_id" json:"oauth2_client_id"` + OAuth2ClientSecret string `db:"oauth2_client_secret" json:"oauth2_client_secret"` + OAuth2ClientSecretKeyID sql.NullString `db:"oauth2_client_secret_key_id" json:"oauth2_client_secret_key_id"` + OAuth2AuthURL string `db:"oauth2_auth_url" json:"oauth2_auth_url"` + OAuth2TokenURL string `db:"oauth2_token_url" json:"oauth2_token_url"` + OAuth2RevocationURL string `db:"oauth2_revocation_url" json:"oauth2_revocation_url"` + OAuth2Resource string `db:"oauth2_resource" json:"oauth2_resource"` + OAuth2Scopes string `db:"oauth2_scopes" json:"oauth2_scopes"` + OAuth2ClientRegistration string `db:"oauth2_client_registration" json:"oauth2_client_registration"` + APIKeyHeader string `db:"api_key_header" json:"api_key_header"` + APIKeyValue string `db:"api_key_value" json:"api_key_value"` + APIKeyValueKeyID sql.NullString `db:"api_key_value_key_id" json:"api_key_value_key_id"` + CustomHeaders string `db:"custom_headers" json:"custom_headers"` + CustomHeadersKeyID sql.NullString `db:"custom_headers_key_id" json:"custom_headers_key_id"` + SigningSecret string `db:"signing_secret" json:"signing_secret"` + SigningSecretKeyID sql.NullString `db:"signing_secret_key_id" json:"signing_secret_key_id"` + ToolAllowList []string `db:"tool_allow_list" json:"tool_allow_list"` + ToolDenyList []string `db:"tool_deny_list" json:"tool_deny_list"` + Availability string `db:"availability" json:"availability"` + Enabled bool `db:"enabled" json:"enabled"` + ModelIntent bool `db:"model_intent" json:"model_intent"` + AllowInPlanMode bool `db:"allow_in_plan_mode" json:"allow_in_plan_mode"` + ForwardCoderHeaders bool `db:"forward_coder_headers" json:"forward_coder_headers"` + GroupACL ChatACL `db:"group_acl" json:"group_acl"` + UserACL ChatACL `db:"user_acl" json:"user_acl"` + CreatedBy uuid.UUID `db:"created_by" json:"created_by"` + UpdatedBy uuid.UUID `db:"updated_by" json:"updated_by"` } func (q *sqlQuerier) InsertMCPServerConfig(ctx context.Context, arg InsertMCPServerConfigParams) (MCPServerConfig, error) { @@ -20759,6 +20769,7 @@ func (q *sqlQuerier) InsertMCPServerConfig(ctx context.Context, arg InsertMCPSer arg.OAuth2RevocationURL, arg.OAuth2Resource, arg.OAuth2Scopes, + arg.OAuth2ClientRegistration, arg.APIKeyHeader, arg.APIKeyValue, arg.APIKeyValueKeyID, @@ -20817,6 +20828,7 @@ func (q *sqlQuerier) InsertMCPServerConfig(ctx context.Context, arg InsertMCPSer &i.SigningSecret, &i.SigningSecretKeyID, &i.OAuth2Resource, + &i.OAuth2ClientRegistration, ) return i, err } @@ -20888,60 +20900,62 @@ SET oauth2_revocation_url = $13::text, oauth2_resource = $14::text, oauth2_scopes = $15::text, - api_key_header = $16::text, - api_key_value = $17::text, - api_key_value_key_id = $18::text, - custom_headers = $19::text, - custom_headers_key_id = $20::text, - signing_secret = $21::text, - signing_secret_key_id = $22::text, - tool_allow_list = $23::text[], - tool_deny_list = $24::text[], - availability = $25::text, - enabled = $26::boolean, - model_intent = $27::boolean, - allow_in_plan_mode = $28::boolean, - forward_coder_headers = $29::boolean, - updated_by = $30::uuid, + oauth2_client_registration = $16::text, + api_key_header = $17::text, + api_key_value = $18::text, + api_key_value_key_id = $19::text, + custom_headers = $20::text, + custom_headers_key_id = $21::text, + signing_secret = $22::text, + signing_secret_key_id = $23::text, + tool_allow_list = $24::text[], + tool_deny_list = $25::text[], + availability = $26::text, + enabled = $27::boolean, + model_intent = $28::boolean, + allow_in_plan_mode = $29::boolean, + forward_coder_headers = $30::boolean, + updated_by = $31::uuid, updated_at = NOW() WHERE - id = $31::uuid + id = $32::uuid RETURNING - id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource + id, display_name, slug, description, icon_url, transport, url, auth_type, oauth2_client_id, oauth2_client_secret, oauth2_client_secret_key_id, oauth2_auth_url, oauth2_token_url, oauth2_scopes, api_key_header, api_key_value, api_key_value_key_id, custom_headers, custom_headers_key_id, tool_allow_list, tool_deny_list, availability, enabled, created_by, updated_by, created_at, updated_at, model_intent, allow_in_plan_mode, forward_coder_headers, oauth2_revocation_url, organization_id, group_acl, user_acl, signing_secret, signing_secret_key_id, oauth2_resource, oauth2_client_registration ` type UpdateMCPServerConfigParams struct { - DisplayName string `db:"display_name" json:"display_name"` - Slug string `db:"slug" json:"slug"` - Description string `db:"description" json:"description"` - IconURL string `db:"icon_url" json:"icon_url"` - Transport string `db:"transport" json:"transport"` - Url string `db:"url" json:"url"` - AuthType string `db:"auth_type" json:"auth_type"` - OAuth2ClientID string `db:"oauth2_client_id" json:"oauth2_client_id"` - OAuth2ClientSecret string `db:"oauth2_client_secret" json:"oauth2_client_secret"` - OAuth2ClientSecretKeyID sql.NullString `db:"oauth2_client_secret_key_id" json:"oauth2_client_secret_key_id"` - OAuth2AuthURL string `db:"oauth2_auth_url" json:"oauth2_auth_url"` - OAuth2TokenURL string `db:"oauth2_token_url" json:"oauth2_token_url"` - OAuth2RevocationURL string `db:"oauth2_revocation_url" json:"oauth2_revocation_url"` - OAuth2Resource string `db:"oauth2_resource" json:"oauth2_resource"` - OAuth2Scopes string `db:"oauth2_scopes" json:"oauth2_scopes"` - APIKeyHeader string `db:"api_key_header" json:"api_key_header"` - APIKeyValue string `db:"api_key_value" json:"api_key_value"` - APIKeyValueKeyID sql.NullString `db:"api_key_value_key_id" json:"api_key_value_key_id"` - CustomHeaders string `db:"custom_headers" json:"custom_headers"` - CustomHeadersKeyID sql.NullString `db:"custom_headers_key_id" json:"custom_headers_key_id"` - SigningSecret string `db:"signing_secret" json:"signing_secret"` - SigningSecretKeyID sql.NullString `db:"signing_secret_key_id" json:"signing_secret_key_id"` - ToolAllowList []string `db:"tool_allow_list" json:"tool_allow_list"` - ToolDenyList []string `db:"tool_deny_list" json:"tool_deny_list"` - Availability string `db:"availability" json:"availability"` - Enabled bool `db:"enabled" json:"enabled"` - ModelIntent bool `db:"model_intent" json:"model_intent"` - AllowInPlanMode bool `db:"allow_in_plan_mode" json:"allow_in_plan_mode"` - ForwardCoderHeaders bool `db:"forward_coder_headers" json:"forward_coder_headers"` - UpdatedBy uuid.UUID `db:"updated_by" json:"updated_by"` - ID uuid.UUID `db:"id" json:"id"` + DisplayName string `db:"display_name" json:"display_name"` + Slug string `db:"slug" json:"slug"` + Description string `db:"description" json:"description"` + IconURL string `db:"icon_url" json:"icon_url"` + Transport string `db:"transport" json:"transport"` + Url string `db:"url" json:"url"` + AuthType string `db:"auth_type" json:"auth_type"` + OAuth2ClientID string `db:"oauth2_client_id" json:"oauth2_client_id"` + OAuth2ClientSecret string `db:"oauth2_client_secret" json:"oauth2_client_secret"` + OAuth2ClientSecretKeyID sql.NullString `db:"oauth2_client_secret_key_id" json:"oauth2_client_secret_key_id"` + OAuth2AuthURL string `db:"oauth2_auth_url" json:"oauth2_auth_url"` + OAuth2TokenURL string `db:"oauth2_token_url" json:"oauth2_token_url"` + OAuth2RevocationURL string `db:"oauth2_revocation_url" json:"oauth2_revocation_url"` + OAuth2Resource string `db:"oauth2_resource" json:"oauth2_resource"` + OAuth2Scopes string `db:"oauth2_scopes" json:"oauth2_scopes"` + OAuth2ClientRegistration string `db:"oauth2_client_registration" json:"oauth2_client_registration"` + APIKeyHeader string `db:"api_key_header" json:"api_key_header"` + APIKeyValue string `db:"api_key_value" json:"api_key_value"` + APIKeyValueKeyID sql.NullString `db:"api_key_value_key_id" json:"api_key_value_key_id"` + CustomHeaders string `db:"custom_headers" json:"custom_headers"` + CustomHeadersKeyID sql.NullString `db:"custom_headers_key_id" json:"custom_headers_key_id"` + SigningSecret string `db:"signing_secret" json:"signing_secret"` + SigningSecretKeyID sql.NullString `db:"signing_secret_key_id" json:"signing_secret_key_id"` + ToolAllowList []string `db:"tool_allow_list" json:"tool_allow_list"` + ToolDenyList []string `db:"tool_deny_list" json:"tool_deny_list"` + Availability string `db:"availability" json:"availability"` + Enabled bool `db:"enabled" json:"enabled"` + ModelIntent bool `db:"model_intent" json:"model_intent"` + AllowInPlanMode bool `db:"allow_in_plan_mode" json:"allow_in_plan_mode"` + ForwardCoderHeaders bool `db:"forward_coder_headers" json:"forward_coder_headers"` + UpdatedBy uuid.UUID `db:"updated_by" json:"updated_by"` + ID uuid.UUID `db:"id" json:"id"` } func (q *sqlQuerier) UpdateMCPServerConfig(ctx context.Context, arg UpdateMCPServerConfigParams) (MCPServerConfig, error) { @@ -20961,6 +20975,7 @@ func (q *sqlQuerier) UpdateMCPServerConfig(ctx context.Context, arg UpdateMCPSer arg.OAuth2RevocationURL, arg.OAuth2Resource, arg.OAuth2Scopes, + arg.OAuth2ClientRegistration, arg.APIKeyHeader, arg.APIKeyValue, arg.APIKeyValueKeyID, @@ -21017,6 +21032,7 @@ func (q *sqlQuerier) UpdateMCPServerConfig(ctx context.Context, arg UpdateMCPSer &i.SigningSecret, &i.SigningSecretKeyID, &i.OAuth2Resource, + &i.OAuth2ClientRegistration, ) return i, err } diff --git a/coderd/database/queries/mcpserverconfigs.sql b/coderd/database/queries/mcpserverconfigs.sql index e7222f2ce0c..79c02e4caa8 100644 --- a/coderd/database/queries/mcpserverconfigs.sql +++ b/coderd/database/queries/mcpserverconfigs.sql @@ -90,6 +90,7 @@ INSERT INTO mcp_server_configs ( oauth2_revocation_url, oauth2_resource, oauth2_scopes, + oauth2_client_registration, api_key_header, api_key_value, api_key_value_key_id, @@ -126,6 +127,7 @@ INSERT INTO mcp_server_configs ( @oauth2_revocation_url::text, @oauth2_resource::text, @oauth2_scopes::text, + @oauth2_client_registration::text, @api_key_header::text, @api_key_value::text, sqlc.narg('api_key_value_key_id')::text, @@ -167,6 +169,7 @@ SET oauth2_revocation_url = @oauth2_revocation_url::text, oauth2_resource = @oauth2_resource::text, oauth2_scopes = @oauth2_scopes::text, + oauth2_client_registration = @oauth2_client_registration::text, api_key_header = @api_key_header::text, api_key_value = @api_key_value::text, api_key_value_key_id = sqlc.narg('api_key_value_key_id')::text, diff --git a/coderd/database/sqlc.yaml b/coderd/database/sqlc.yaml index f67a9c29f21..75b6fdcd729 100644 --- a/coderd/database/sqlc.yaml +++ b/coderd/database/sqlc.yaml @@ -325,6 +325,7 @@ sql: oauth2_revocation_url: OAuth2RevocationURL oauth2_resource: OAuth2Resource oauth2_scopes: OAuth2Scopes + oauth2_client_registration: OAuth2ClientRegistration api_key_header: APIKeyHeader api_key_value: APIKeyValue api_key_value_key_id: APIKeyValueKeyID diff --git a/coderd/mcp.go b/coderd/mcp.go index c3ecb9d87b2..aad8a2fd4d7 100644 --- a/coderd/mcp.go +++ b/coderd/mcp.go @@ -339,6 +339,7 @@ func (api *API) createMCPServerConfig(rw http.ResponseWriter, r *http.Request) { } configID := uuid.New() + oauth2ClientRegistration := codersdk.MCPServerOAuth2ClientRegistrationManual // Validate auth-type-dependent fields. switch req.AuthType { @@ -401,6 +402,7 @@ func (api *API) createMCPServerConfig(rw http.ResponseWriter, r *http.Request) { req.OAuth2Resource = result.resource } req.OAuth2Scopes = oauth2Scopes + oauth2ClientRegistration = codersdk.MCPServerOAuth2ClientRegistrationDynamic } else if req.OAuth2ClientID == "" || req.OAuth2AuthURL == "" || req.OAuth2TokenURL == "" { // Partial manual config: all three fields are required together. httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ @@ -434,37 +436,38 @@ func (api *API) createMCPServerConfig(rw http.ResponseWriter, r *http.Request) { } inserted, err := api.Database.InsertMCPServerConfig(ctx, database.InsertMCPServerConfigParams{ - ID: configID, - OrganizationID: organization.ID, - DisplayName: strings.TrimSpace(req.DisplayName), - Slug: strings.TrimSpace(req.Slug), - Description: strings.TrimSpace(req.Description), - IconURL: strings.TrimSpace(req.IconURL), - Transport: strings.TrimSpace(req.Transport), - Url: strings.TrimSpace(req.URL), - AuthType: strings.TrimSpace(req.AuthType), - OAuth2ClientID: strings.TrimSpace(req.OAuth2ClientID), - OAuth2ClientSecret: strings.TrimSpace(req.OAuth2ClientSecret), - OAuth2ClientSecretKeyID: sql.NullString{}, - OAuth2AuthURL: strings.TrimSpace(req.OAuth2AuthURL), - OAuth2TokenURL: strings.TrimSpace(req.OAuth2TokenURL), - OAuth2RevocationURL: strings.TrimSpace(req.OAuth2RevocationURL), - OAuth2Resource: strings.TrimSpace(req.OAuth2Resource), - OAuth2Scopes: strings.TrimSpace(req.OAuth2Scopes), - APIKeyHeader: strings.TrimSpace(req.APIKeyHeader), - APIKeyValue: strings.TrimSpace(req.APIKeyValue), - APIKeyValueKeyID: sql.NullString{}, - CustomHeaders: customHeadersJSON, - CustomHeadersKeyID: sql.NullString{}, - SigningSecret: strings.TrimSpace(req.SigningSecret), - SigningSecretKeyID: sql.NullString{}, - ToolAllowList: coalesceStringSlice(trimStringSlice(req.ToolAllowList)), - ToolDenyList: coalesceStringSlice(trimStringSlice(req.ToolDenyList)), - Availability: strings.TrimSpace(req.Availability), - Enabled: req.Enabled, - ModelIntent: req.ModelIntent, - AllowInPlanMode: req.AllowInPlanMode, - ForwardCoderHeaders: req.ForwardCoderHeaders, + ID: configID, + OrganizationID: organization.ID, + DisplayName: strings.TrimSpace(req.DisplayName), + Slug: strings.TrimSpace(req.Slug), + Description: strings.TrimSpace(req.Description), + IconURL: strings.TrimSpace(req.IconURL), + Transport: strings.TrimSpace(req.Transport), + Url: strings.TrimSpace(req.URL), + AuthType: strings.TrimSpace(req.AuthType), + OAuth2ClientID: strings.TrimSpace(req.OAuth2ClientID), + OAuth2ClientSecret: strings.TrimSpace(req.OAuth2ClientSecret), + OAuth2ClientSecretKeyID: sql.NullString{}, + OAuth2AuthURL: strings.TrimSpace(req.OAuth2AuthURL), + OAuth2TokenURL: strings.TrimSpace(req.OAuth2TokenURL), + OAuth2RevocationURL: strings.TrimSpace(req.OAuth2RevocationURL), + OAuth2Resource: strings.TrimSpace(req.OAuth2Resource), + OAuth2Scopes: strings.TrimSpace(req.OAuth2Scopes), + OAuth2ClientRegistration: string(oauth2ClientRegistration), + APIKeyHeader: strings.TrimSpace(req.APIKeyHeader), + APIKeyValue: strings.TrimSpace(req.APIKeyValue), + APIKeyValueKeyID: sql.NullString{}, + CustomHeaders: customHeadersJSON, + CustomHeadersKeyID: sql.NullString{}, + SigningSecret: strings.TrimSpace(req.SigningSecret), + SigningSecretKeyID: sql.NullString{}, + ToolAllowList: coalesceStringSlice(trimStringSlice(req.ToolAllowList)), + ToolDenyList: coalesceStringSlice(trimStringSlice(req.ToolDenyList)), + Availability: strings.TrimSpace(req.Availability), + Enabled: req.Enabled, + ModelIntent: req.ModelIntent, + AllowInPlanMode: req.AllowInPlanMode, + ForwardCoderHeaders: req.ForwardCoderHeaders, GroupACL: database.ChatACL{ organization.ID.String(): {Permissions: []policy.Action{policy.ActionRead}}, }, @@ -691,6 +694,9 @@ func (api *API) updateMCPServerConfig(rw http.ResponseWriter, r *http.Request) { } next := applyMCPServerConfigChange(existing, req, customHeadersJSON) + if next.OAuth2ClientRegistration == string(codersdk.MCPServerOAuth2ClientRegistrationDynamic) && changesDynamicOAuth2Client(existing, req) { + next.OAuth2ClientRegistration = string(codersdk.MCPServerOAuth2ClientRegistrationManual) + } if next.AuthType == "api_key" && (next.APIKeyHeader == "" || next.APIKeyValue == "") { return errAPIKeyAuthRequiresHeaderAndValue } @@ -702,37 +708,38 @@ func (api *API) updateMCPServerConfig(rw http.ResponseWriter, r *http.Request) { } updatedConfig, err := tx.UpdateMCPServerConfig(ctx, database.UpdateMCPServerConfigParams{ - DisplayName: next.DisplayName, - Slug: next.Slug, - Description: next.Description, - IconURL: next.IconURL, - Transport: next.Transport, - Url: next.Url, - AuthType: next.AuthType, - OAuth2ClientID: next.OAuth2ClientID, - OAuth2ClientSecret: next.OAuth2ClientSecret, - OAuth2ClientSecretKeyID: next.OAuth2ClientSecretKeyID, - OAuth2AuthURL: next.OAuth2AuthURL, - OAuth2TokenURL: next.OAuth2TokenURL, - OAuth2RevocationURL: next.OAuth2RevocationURL, - OAuth2Resource: next.OAuth2Resource, - OAuth2Scopes: next.OAuth2Scopes, - APIKeyHeader: next.APIKeyHeader, - APIKeyValue: next.APIKeyValue, - APIKeyValueKeyID: next.APIKeyValueKeyID, - CustomHeaders: next.CustomHeaders, - CustomHeadersKeyID: next.CustomHeadersKeyID, - SigningSecret: next.SigningSecret, - SigningSecretKeyID: next.SigningSecretKeyID, - ToolAllowList: next.ToolAllowList, - ToolDenyList: next.ToolDenyList, - Availability: next.Availability, - Enabled: next.Enabled, - ModelIntent: next.ModelIntent, - AllowInPlanMode: next.AllowInPlanMode, - ForwardCoderHeaders: next.ForwardCoderHeaders, - UpdatedBy: apiKey.UserID, - ID: existing.ID, + DisplayName: next.DisplayName, + Slug: next.Slug, + Description: next.Description, + IconURL: next.IconURL, + Transport: next.Transport, + Url: next.Url, + AuthType: next.AuthType, + OAuth2ClientID: next.OAuth2ClientID, + OAuth2ClientSecret: next.OAuth2ClientSecret, + OAuth2ClientSecretKeyID: next.OAuth2ClientSecretKeyID, + OAuth2AuthURL: next.OAuth2AuthURL, + OAuth2TokenURL: next.OAuth2TokenURL, + OAuth2RevocationURL: next.OAuth2RevocationURL, + OAuth2Resource: next.OAuth2Resource, + OAuth2Scopes: next.OAuth2Scopes, + OAuth2ClientRegistration: next.OAuth2ClientRegistration, + APIKeyHeader: next.APIKeyHeader, + APIKeyValue: next.APIKeyValue, + APIKeyValueKeyID: next.APIKeyValueKeyID, + CustomHeaders: next.CustomHeaders, + CustomHeadersKeyID: next.CustomHeadersKeyID, + SigningSecret: next.SigningSecret, + SigningSecretKeyID: next.SigningSecretKeyID, + ToolAllowList: next.ToolAllowList, + ToolDenyList: next.ToolDenyList, + Availability: next.Availability, + Enabled: next.Enabled, + ModelIntent: next.ModelIntent, + AllowInPlanMode: next.AllowInPlanMode, + ForwardCoderHeaders: next.ForwardCoderHeaders, + UpdatedBy: apiKey.UserID, + ID: existing.ID, }) if err != nil { return err @@ -868,6 +875,7 @@ func clearUnusedMCPServerAuthFields(c database.MCPServerConfig) database.MCPServ c.OAuth2RevocationURL = "" c.OAuth2Resource = "" c.OAuth2Scopes = "" + c.OAuth2ClientRegistration = string(codersdk.MCPServerOAuth2ClientRegistrationManual) } if !usesAPIKey { c.APIKeyHeader = "" @@ -881,6 +889,18 @@ func clearUnusedMCPServerAuthFields(c database.MCPServerConfig) database.MCPServ return c } +// changesDynamicOAuth2Client reports whether req changes a field that +// Coder owns for a dynamic OAuth2 client. +func changesDynamicOAuth2Client(prev database.MCPServerConfig, req codersdk.UpdateMCPServerConfigRequest) bool { + changes := func(v *string, prevValue string) bool { + return v != nil && strings.TrimSpace(*v) != prevValue + } + return changes(req.OAuth2ClientID, prev.OAuth2ClientID) || + changes(req.OAuth2ClientSecret, prev.OAuth2ClientSecret) || + changes(req.OAuth2AuthURL, prev.OAuth2AuthURL) || + changes(req.OAuth2TokenURL, prev.OAuth2TokenURL) +} + // mcpOAuth2GrantBinding holds the config fields that a stored user grant // is bound to: the destination, the auth flow, the token and revocation // endpoints, the OAuth client, and the resource indicator. When any of @@ -1591,6 +1611,8 @@ func convertMCPServerConfig(config database.MCPServerConfig) codersdk.MCPServerC OAuth2Resource: config.OAuth2Resource, OAuth2Scopes: config.OAuth2Scopes, + OAuth2ClientRegistration: codersdk.MCPServerOAuth2ClientRegistration(config.OAuth2ClientRegistration), + APIKeyHeader: config.APIKeyHeader, HasAPIKey: config.APIKeyValue != "", @@ -1628,6 +1650,7 @@ func convertMCPServerConfigRedacted(config database.MCPServerConfig) codersdk.MC c.OAuth2RevocationURL = "" c.OAuth2Resource = "" c.OAuth2Scopes = "" + c.OAuth2ClientRegistration = "" c.APIKeyHeader = "" return c } diff --git a/coderd/mcp_test.go b/coderd/mcp_test.go index 95b0580068b..02efe94e938 100644 --- a/coderd/mcp_test.go +++ b/coderd/mcp_test.go @@ -2549,6 +2549,7 @@ func TestMCPServerConfigsOAuth2AutoDiscovery(t *testing.T) { create := testutil.RequireReceive(ctx, t, createdCh) require.NoError(t, create.err) created := create.config + require.Equal(t, codersdk.MCPServerOAuth2ClientRegistrationDynamic, created.OAuth2ClientRegistration) require.Equal(t, "auto-discovered-client-id", created.OAuth2ClientID) require.True(t, created.HasOAuth2Secret) require.Equal(t, authServer.URL+"/authorize", created.OAuth2AuthURL) @@ -2575,6 +2576,29 @@ func TestMCPServerConfigsOAuth2AutoDiscovery(t *testing.T) { require.NoError(t, err) require.Equal(t, "https://override.example.com/revoke", overridden.OAuth2RevocationURL) require.Equal(t, "https://override.example.com/mcp", overridden.OAuth2Resource) + + // Resending the registered client ID keeps the client dynamic, and + // replacing it makes the client manual. + updated, err := client.UpdateMCPServerConfig(ctx, overridden.OrganizationID, overridden.ID, codersdk.UpdateMCPServerConfigRequest{ + OAuth2ClientID: &overridden.OAuth2ClientID, + }) + require.NoError(t, err) + require.Equal(t, codersdk.MCPServerOAuth2ClientRegistrationDynamic, updated.OAuth2ClientRegistration) + replacedClientID := "replaced-client-id" + updated, err = client.UpdateMCPServerConfig(ctx, overridden.OrganizationID, overridden.ID, codersdk.UpdateMCPServerConfigRequest{ + OAuth2ClientID: &replacedClientID, + }) + require.NoError(t, err) + require.Equal(t, codersdk.MCPServerOAuth2ClientRegistrationManual, updated.OAuth2ClientRegistration) + + // Leaving oauth2 resets the registration method with the other + // OAuth2 fields. + authTypeNone := "none" + updated, err = client.UpdateMCPServerConfig(ctx, created.OrganizationID, created.ID, codersdk.UpdateMCPServerConfigRequest{ + AuthType: &authTypeNone, + }) + require.NoError(t, err) + require.Equal(t, codersdk.MCPServerOAuth2ClientRegistrationManual, updated.OAuth2ClientRegistration) }) t.Run("CreateOnlyScopeAllowed", func(t *testing.T) { @@ -3131,6 +3155,7 @@ func TestMCPServerConfigsOAuth2AutoDiscovery(t *testing.T) { ToolDenyList: []string{}, }) require.NoError(t, err) + require.Equal(t, codersdk.MCPServerOAuth2ClientRegistrationManual, created.OAuth2ClientRegistration) require.Equal(t, "manual-client-id", created.OAuth2ClientID) require.Equal(t, "https://auth.example.com/authorize", created.OAuth2AuthURL) require.Equal(t, "https://auth.example.com/token", created.OAuth2TokenURL) diff --git a/coderd/x/chatd/turn_environment_internal_test.go b/coderd/x/chatd/turn_environment_internal_test.go index 007ef1b636f..d2a68b56a6d 100644 --- a/coderd/x/chatd/turn_environment_internal_test.go +++ b/coderd/x/chatd/turn_environment_internal_test.go @@ -1553,19 +1553,20 @@ func TestEnabledMCPServerConfigsForChatOrg(t *testing.T) { chatOrg := dbgen.Organization(t, db, database.Organization{}) user := dbgen.User(t, db, database.User{}) disabledCfg, err := db.InsertMCPServerConfig(ctx, database.InsertMCPServerConfigParams{ - ID: uuid.New(), - OrganizationID: chatOrg.ID, - DisplayName: "Disabled MCP Server", - Slug: testutil.GetRandomName(t), - Url: "https://mcp.example.com", - Transport: "streamable_http", - AuthType: "none", - ToolAllowList: []string{}, - ToolDenyList: []string{}, - Availability: "default_off", - Enabled: false, - CreatedBy: user.ID, - UpdatedBy: user.ID, + ID: uuid.New(), + OrganizationID: chatOrg.ID, + DisplayName: "Disabled MCP Server", + Slug: testutil.GetRandomName(t), + Url: "https://mcp.example.com", + Transport: "streamable_http", + AuthType: "none", + OAuth2ClientRegistration: "manual", + ToolAllowList: []string{}, + ToolDenyList: []string{}, + Availability: "default_off", + Enabled: false, + CreatedBy: user.ID, + UpdatedBy: user.ID, }) require.NoError(t, err) diff --git a/codersdk/mcp.go b/codersdk/mcp.go index f033cb2e292..a5cce14945d 100644 --- a/codersdk/mcp.go +++ b/codersdk/mcp.go @@ -53,6 +53,20 @@ func (c *Client) MCPServerOAuth2DisconnectWithResponse(ctx context.Context, id u return resp, ReadBodyAsJSON(res, &resp) } +// MCPServerOAuth2ClientRegistration is how Coder got the OAuth2 client of +// an MCP server config. +type MCPServerOAuth2ClientRegistration string + +const ( + // MCPServerOAuth2ClientRegistrationManual means an admin registered the + // client and entered its credentials and endpoints. + MCPServerOAuth2ClientRegistrationManual MCPServerOAuth2ClientRegistration = "manual" + // MCPServerOAuth2ClientRegistrationDynamic means Coder discovered the + // endpoints and registered the client with RFC 7591 Dynamic Client + // Registration. + MCPServerOAuth2ClientRegistrationDynamic MCPServerOAuth2ClientRegistration = "dynamic" +) + // MCPServerConfig represents an admin-configured MCP server. type MCPServerConfig struct { ID uuid.UUID `json:"id" format:"uuid"` @@ -76,6 +90,8 @@ type MCPServerConfig struct { OAuth2Resource string `json:"oauth2_resource,omitempty"` OAuth2Scopes string `json:"oauth2_scopes,omitempty"` + OAuth2ClientRegistration MCPServerOAuth2ClientRegistration `json:"oauth2_client_registration,omitempty"` + // API key fields (only populated for admins). APIKeyHeader string `json:"api_key_header,omitempty"` HasAPIKey bool `json:"has_api_key"` diff --git a/docs/admin/security/audit-logs.md b/docs/admin/security/audit-logs.md index 22de9820358..922be09053e 100644 --- a/docs/admin/security/audit-logs.md +++ b/docs/admin/security/audit-logs.md @@ -543,6 +543,7 @@ Actions: `create`, `write`, `delete` model_intentYes oauth2_auth_urlYes oauth2_client_idYes +oauth2_client_registrationYes oauth2_client_secretYes oauth2_client_secret_key_idNo oauth2_resourceYes diff --git a/docs/reference/api/schemas.md b/docs/reference/api/schemas.md index 1046a298934..d7eeabeb5b5 100644 --- a/docs/reference/api/schemas.md +++ b/docs/reference/api/schemas.md @@ -11323,6 +11323,7 @@ Git clone makes use of this by parsing the URL from: 'Username for "https://gith "model_intent": true, "oauth2_auth_url": "string", "oauth2_client_id": "string", + "oauth2_client_registration": "manual", "oauth2_resource": "string", "oauth2_revocation_url": "string", "oauth2_scopes": "string", @@ -11343,38 +11344,39 @@ Git clone makes use of this by parsing the URL from: 'Username for "https://gith ### Properties -| Name | Type | Required | Restrictions | Description | -|-------------------------|-----------------|----------|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `allow_in_plan_mode` | boolean | false | | | -| `api_key_header` | string | false | | Api key header key fields (only populated for admins). | -| `auth_connected` | boolean | false | | Per-user state (populated for non-admin requests). | -| `auth_type` | string | false | | "none", "oauth2", "api_key", "custom_headers", "user_oidc" | -| `availability` | string | false | | Availability policy set by admin. | -| `created_at` | string | false | | | -| `description` | string | false | | | -| `display_name` | string | false | | | -| `enabled` | boolean | false | | | -| `forward_coder_headers` | boolean | false | | Forward coder headers forwards the same Coder identity headers we send to LLM providers (X-Coder-Owner-Id, X-Coder-Chat-Id, and the optional X-Coder-Subchat-Id and X-Coder-Workspace-Id) to this MCP server on every request. Off by default to avoid leaking chat identity to third-party servers. | -| `has_api_key` | boolean | false | | | -| `has_custom_headers` | boolean | false | | | -| `has_oauth2_secret` | boolean | false | | | -| `has_signing_secret` | boolean | false | | | -| `icon_url` | string | false | | | -| `id` | string | false | | | -| `model_intent` | boolean | false | | | -| `oauth2_auth_url` | string | false | | | -| `oauth2_client_id` | string | false | | Oauth2 client ID fields (only populated for admins). | -| `oauth2_resource` | string | false | | | -| `oauth2_revocation_url` | string | false | | | -| `oauth2_scopes` | string | false | | | -| `oauth2_token_url` | string | false | | | -| `organization_id` | string | false | | | -| `slug` | string | false | | | -| `tool_allow_list` | array of string | false | | Tool governance. | -| `tool_deny_list` | array of string | false | | | -| `transport` | string | false | | "streamable_http" or "sse" | -| `updated_at` | string | false | | | -| `url` | string | false | | | +| Name | Type | Required | Restrictions | Description | +|------------------------------|------------------------------------------------------------------------------------------|----------|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `allow_in_plan_mode` | boolean | false | | | +| `api_key_header` | string | false | | Api key header key fields (only populated for admins). | +| `auth_connected` | boolean | false | | Per-user state (populated for non-admin requests). | +| `auth_type` | string | false | | "none", "oauth2", "api_key", "custom_headers", "user_oidc" | +| `availability` | string | false | | Availability policy set by admin. | +| `created_at` | string | false | | | +| `description` | string | false | | | +| `display_name` | string | false | | | +| `enabled` | boolean | false | | | +| `forward_coder_headers` | boolean | false | | Forward coder headers forwards the same Coder identity headers we send to LLM providers (X-Coder-Owner-Id, X-Coder-Chat-Id, and the optional X-Coder-Subchat-Id and X-Coder-Workspace-Id) to this MCP server on every request. Off by default to avoid leaking chat identity to third-party servers. | +| `has_api_key` | boolean | false | | | +| `has_custom_headers` | boolean | false | | | +| `has_oauth2_secret` | boolean | false | | | +| `has_signing_secret` | boolean | false | | | +| `icon_url` | string | false | | | +| `id` | string | false | | | +| `model_intent` | boolean | false | | | +| `oauth2_auth_url` | string | false | | | +| `oauth2_client_id` | string | false | | Oauth2 client ID fields (only populated for admins). | +| `oauth2_client_registration` | [codersdk.MCPServerOAuth2ClientRegistration](#codersdkmcpserveroauth2clientregistration) | false | | | +| `oauth2_resource` | string | false | | | +| `oauth2_revocation_url` | string | false | | | +| `oauth2_scopes` | string | false | | | +| `oauth2_token_url` | string | false | | | +| `organization_id` | string | false | | | +| `slug` | string | false | | | +| `tool_allow_list` | array of string | false | | Tool governance. | +| `tool_deny_list` | array of string | false | | | +| `transport` | string | false | | "streamable_http" or "sse" | +| `updated_at` | string | false | | | +| `url` | string | false | | | ## codersdk.MCPServerConfigACL @@ -11529,6 +11531,20 @@ Git clone makes use of this by parsing the URL from: 'Username for "https://gith |----------|----------| | `role` | `read` | +## codersdk.MCPServerOAuth2ClientRegistration + +```json +"manual" +``` + +### Properties + +#### Enumerated Values + +| Value(s) | +|---------------------| +| `dynamic`, `manual` | + ## codersdk.MCPServerOAuth2DisconnectResponse ```json diff --git a/enterprise/audit/table.go b/enterprise/audit/table.go index 14b8ef80422..678a57278d1 100644 --- a/enterprise/audit/table.go +++ b/enterprise/audit/table.go @@ -596,6 +596,7 @@ var auditableResourcesTypes = map[any]map[string]Action{ "user_acl": ActionTrack, "oauth2_revocation_url": ActionTrack, "oauth2_resource": ActionTrack, + "oauth2_client_registration": ActionTrack, "organization_id": ActionIgnore, }, &database.Skill{}: { diff --git a/enterprise/dbcrypt/dbcrypt_internal_test.go b/enterprise/dbcrypt/dbcrypt_internal_test.go index f80baddb2d2..361604efcbe 100644 --- a/enterprise/dbcrypt/dbcrypt_internal_test.go +++ b/enterprise/dbcrypt/dbcrypt_internal_test.go @@ -1119,23 +1119,24 @@ func TestMCPServerConfigs(t *testing.T) { newSigningSecret = "updated-signing-secret" ) updated, err := crypt.UpdateMCPServerConfig(ctx, database.UpdateMCPServerConfigParams{ - ID: cfg.ID, - DisplayName: cfg.DisplayName, - Slug: cfg.Slug, - Description: cfg.Description, - Url: cfg.Url, - Transport: cfg.Transport, - AuthType: cfg.AuthType, - OAuth2ClientID: cfg.OAuth2ClientID, - OAuth2ClientSecret: newSecret, - APIKeyValue: newAPIKey, - CustomHeaders: newHeaders, - SigningSecret: newSigningSecret, - ToolAllowList: cfg.ToolAllowList, - ToolDenyList: cfg.ToolDenyList, - Availability: cfg.Availability, - Enabled: cfg.Enabled, - UpdatedBy: cfg.CreatedBy.UUID, + ID: cfg.ID, + DisplayName: cfg.DisplayName, + Slug: cfg.Slug, + Description: cfg.Description, + Url: cfg.Url, + Transport: cfg.Transport, + AuthType: cfg.AuthType, + OAuth2ClientID: cfg.OAuth2ClientID, + OAuth2ClientSecret: newSecret, + OAuth2ClientRegistration: cfg.OAuth2ClientRegistration, + APIKeyValue: newAPIKey, + CustomHeaders: newHeaders, + SigningSecret: newSigningSecret, + ToolAllowList: cfg.ToolAllowList, + ToolDenyList: cfg.ToolDenyList, + Availability: cfg.Availability, + Enabled: cfg.Enabled, + UpdatedBy: cfg.CreatedBy.UUID, }) require.NoError(t, err) requireMCPServerConfigDecrypted(t, updated, ciphers, newSecret, newAPIKey, newHeaders, newSigningSecret) diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index a83157fd619..eddff3d824b 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -6813,6 +6813,7 @@ export interface MCPServerConfig { readonly oauth2_revocation_url?: string; readonly oauth2_resource?: string; readonly oauth2_scopes?: string; + readonly oauth2_client_registration?: MCPServerOAuth2ClientRegistration; /** * API key fields (only populated for admins). */ @@ -6879,6 +6880,12 @@ export interface MCPServerConfigUser extends MinimalUser { readonly role: MCPServerConfigRole; } +// From codersdk/mcp.go +export type MCPServerOAuth2ClientRegistration = "dynamic" | "manual"; + +export const MCPServerOAuth2ClientRegistrations: MCPServerOAuth2ClientRegistration[] = + ["dynamic", "manual"]; + // From codersdk/mcp.go /** * MCPServerOAuth2DisconnectResponse reports whether the removed token