---
title: "Create an MCP OAuth auth config by discovery"
url: https://hexelstudio.com/docs/api/titan/connections/mcp-oauth
---

# Create an MCP OAuth auth config by discovery

**POST** `/titan/tools/auth-configs/mcp-oauth`

Discovers the registered MCP server's authorization (RFC 9728 protected-resource metadata, RFC 8414 or OpenID Connect authorization-server metadata), registers a client (RFC 7591) unless a pre-registered client is given, and creates an oauth2 auth config with pkce S256 and the RFC 8707 resource indicator. Connect with POST /v1/connections/initiate.

Requires permission `tool-gateway:auth:write`.

## Headers

- `Authorization: string`

  `Bearer <token>`. A Hexel Studio access token for a member or a service user of your organization (or send a service user's API key as X-API-Key).

- `X-Workspace-Id: optional string`

  Workspace scope used by permission checks, if applicable.

- `X-Environment-Id: optional string`

  Optional environment scope.

## Body parameters

- `client: optional object`

  Client is a pre-registered client; omitted registers one with RFC 7591.

  - `client_id: optional string`

  - `client_secret: optional string`

  - `token_endpoint_auth: optional string`

- `name: optional string`

- `redirect_uri: string`

  RedirectURI is the OAuth callback the client registers and later
authorization requests use.

- `resource_metadata_url: optional string`

  ResourceMetadataURL is an RFC 9728 metadata URL to use instead of
probing the server.

- `scopes: optional array of string`

- `toolkit_slug: string`

  ToolkitSlug is the MCP toolkit MCP_<SERVER>; its registered server is
the one discovered.

- `workspace_id: optional string`

## Returns

`201` Created (`MCPOAuthConfigResponse`)

- `auth_config: optional AuthConfig`

  - `auth_config_id: optional string`

  - `auth_scheme: optional string`

  - `auth_url: optional string`

  - `client_id: optional string`

  - `created_at: optional string`

  - `credential_fields: optional array of CredentialField`

    CredentialFields declares the named credential fields a static-token
connection of this config holds.

    - `name: optional string`

      Name is the field name a tool's credential placement refers to:
[a-z_]{1,32}.

    - `pattern: optional string`

      Pattern is an optional RE2 expression the whole value must match.

    - `secret: optional boolean`

      Secret marks a value that is never returned or shown. It defaults to
true. A non-secret field named like a connection attribute (site,
subdomain, region, instance_url) is also kept as a plaintext attribute;
every other field exists only encrypted.

  - `extra_authorize_params: optional map[string]`

  - `grant_type: optional string`

    GrantType is authorization_code (the default), or client_credentials
or account_credentials for an app config. It is
fixed when the config is created.

  - `header_name: optional string`

  - `is_active: optional boolean`

  - `is_default: optional boolean`

    Mark as default for this level

  - `name: optional string`

  - `organization_id: optional string`

    NULL = platform default

  - `pkce: optional string`

    OAuth2 client options; each defaults to the
previous behaviour.

  - `resource: optional string`

    Resource is the RFC 8707 resource indicator sent on the authorization
and token requests: the MCP server a token is
for. Nil sends none.

  - `scope_delimiter: optional string`

  - `scopes: optional array of string`

  - `token_endpoint_auth: optional string`

  - `token_request_format: optional string`

    TokenRequestFormat encodes every token request body: "form" (the
default, RFC 6749) or "json" (a JSON object of the same parameters,
as Zendesk documents). Client authentication is unchanged.

  - `token_response: optional TokenResponse`

    - `access_token: optional string`

    - `attributes: optional map[string]`

    - `default_expires_in: optional integer`

    - `expires_in: optional string`

    - `refresh: optional TokenPaths`

      - `access_token: optional string`

      - `expires_in: optional string`

      - `refresh_token: optional string`

      - `scope: optional string`

    - `refresh_token: optional string`

    - `scope: optional string`

  - `token_url: optional string`

  - `toolkit_slug: optional string`

  - `updated_at: optional string`

  - `workspace_id: optional string`

    NULL = org-level

- `discovery: optional ToolsPlan`

  - `authorization_endpoint: optional string`

  - `authorization_server_metadata_url: optional string`

  - `issuer: optional string`

  - `registration: optional string`

    Registration is "dynamic" (RFC 7591) or "pre_registered".

  - `resource: optional string`

  - `resource_metadata_url: optional string`

  - `scopes: optional array of string`

  - `server_url: optional string`

  - `token_endpoint: optional string`

## Errors

- `400` Bad Request
- `401` Unauthenticated: token missing or rejected at the edge
- `403` Forbidden: caller lacks the required permission
- `502` Bad Gateway

## Example

```bash
curl --request POST \
  --url 'https://api.hexelstudio.com/v1/titan/tools/auth-configs/mcp-oauth' \
  --header "Authorization: Bearer $ACCESS_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{
  "client": {
    "client_id": "string",
    "client_secret": "string",
    "token_endpoint_auth": "string"
  },
  "name": "string",
  "redirect_uri": "string",
  "resource_metadata_url": "string",
  "scopes": [
    "string"
  ],
  "toolkit_slug": "string",
  "workspace_id": "string"
}'
```

### Response (201)

```json
{
  "auth_config": {
    "auth_config_id": "string",
    "auth_scheme": "string",
    "auth_url": "string",
    "client_id": "string",
    "created_at": "2026-01-01T00:00:00Z",
    "credential_fields": [
      {
        "name": "string",
        "pattern": "string",
        "secret": true
      }
    ],
    "extra_authorize_params": {
      "key": "string"
    },
    "grant_type": "string",
    "header_name": "string",
    "is_active": true,
    "is_default": true,
    "name": "string",
    "organization_id": "string",
    "pkce": "string",
    "resource": "string",
    "scope_delimiter": "string",
    "scopes": [
      "string"
    ],
    "token_endpoint_auth": "string",
    "token_request_format": "string",
    "token_response": {
      "access_token": "string",
      "attributes": {
        "key": "string"
      },
      "default_expires_in": 0,
      "expires_in": "string",
      "refresh": {
        "access_token": "string",
        "expires_in": "string",
        "refresh_token": "string",
        "scope": "string"
      },
      "refresh_token": "string",
      "scope": "string"
    },
    "token_url": "string",
    "toolkit_slug": "string",
    "updated_at": "2026-01-01T00:00:00Z",
    "workspace_id": "string"
  },
  "discovery": {
    "authorization_endpoint": "string",
    "authorization_server_metadata_url": "string",
    "issuer": "string",
    "registration": "string",
    "resource": "string",
    "resource_metadata_url": "string",
    "scopes": [
      "string"
    ],
    "server_url": "string",
    "token_endpoint": "string"
  }
}
```

### Response (400)

```json
{
  "error": {
    "code": "string",
    "message": "string"
  }
}
```

### Response (502)

```json
{
  "error": {
    "code": "string",
    "message": "string"
  }
}
```
