# Register a client

Source: https://docs.musicnerd.net/api-reference/oauth/register-client

Register a client

## POST /api/oauth/reg

Full OpenAPI specification: https://docs.musicnerd.net/spec/oauth.json

## Authentication

This operation's specification permits a request without authentication.

[Authentication guide](https://docs.musicnerd.net/authentication)

## Operation and referenced schemas

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Music Nerd API: OAuth",
    "version": "1.0.0",
    "description": "How agents connect to the MCP server with OAuth: the discovery documents an MCP client reads, and the member's list of connected agents."
  },
  "servers": [
    {
      "url": "https://api.musicnerd.net",
      "description": "Production"
    },
    {
      "url": "https://musicnerd-api-staging.vercel.app",
      "description": "Staging (staging database)"
    }
  ],
  "paths": {
    "/api/oauth/reg": {
      "post": {
        "summary": "Register a client",
        "operationId": "registerOAuthClient",
        "security": [],
        "description": "Registers an MCP client (RFC 7591) and returns its `client_id`. Redirect URIs must use HTTPS, or HTTP on `localhost` or `127.0.0.1`. Clients get no secret and prove themselves with PKCE instead.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "redirect_uris"
                ],
                "properties": {
                  "client_name": {
                    "type": "string",
                    "maxLength": 200,
                    "description": "The agent's name, shown when the user approves it. Not verified."
                  },
                  "redirect_uris": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "string",
                      "format": "uri"
                    },
                    "description": "Where to send the user back after approving."
                  },
                  "grant_types": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Ignored; the client always gets `authorization_code` and `refresh_token`."
                  },
                  "token_endpoint_auth_method": {
                    "type": "string",
                    "description": "Ignored; always `none`."
                  }
                }
              },
              "example": {
                "client_name": "Claude",
                "redirect_uris": [
                  "http://127.0.0.1:33418/callback"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Registered.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientRegistration"
                },
                "example": {
                  "client_id": "2f6c1d0e-8a4b-4c47-9a51-3e0f7b9d2c18",
                  "client_name": "Claude",
                  "redirect_uris": [
                    "http://127.0.0.1:33418/callback"
                  ],
                  "grant_types": [
                    "authorization_code",
                    "refresh_token"
                  ],
                  "response_types": [
                    "code"
                  ],
                  "token_endpoint_auth_method": "none"
                }
              }
            }
          },
          "400": {
            "description": "A redirect URI is missing or not allowed (`invalid_redirect_uri`), or the body is invalid (`invalid_client_metadata`). Errors use the standard OAuth shape.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "invalid_redirect_uri",
                  "error_description": "Redirect URIs must use https, or http on localhost"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ClientRegistration": {
        "type": "object",
        "required": [
          "client_id",
          "redirect_uris",
          "grant_types",
          "response_types",
          "token_endpoint_auth_method"
        ],
        "properties": {
          "client_id": {
            "type": "string"
          },
          "client_name": {
            "type": "string"
          },
          "redirect_uris": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "grant_types": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "response_types": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "token_endpoint_auth_method": {
            "type": "string",
            "enum": [
              "none"
            ]
          }
        }
      },
      "OAuthError": {
        "type": "object",
        "description": "The standard OAuth error shape (RFC 6749), used by registration, authorization and the token endpoint instead of `{status, error}`.",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "An OAuth error code, like `invalid_grant`."
          },
          "error_description": {
            "type": "string"
          }
        }
      }
    }
  }
}
```
