# The Creators Company auth.md

You are an agent. This file tells you how to get credentials to act for a The Creators Company user: a creator who runs a storefront selling digital products and courses.

The Creators Company does not offer autonomous agent sign-up. There is no `/agent/identity` endpoint and no `agent_auth` block. Access always goes through a human: you register an OAuth client, then the user signs in and approves you in their browser. If you have no user who can do that, stop here.

## What you can access

- **API:** Model Context Protocol (MCP) over Streamable HTTP, JSON-RPC 2.0
- **Endpoint:** `https://thecreators.company/mcp`
- **Scope:** `mcp:use` (products, course content, orders, customers, domains, store settings and pages, limited to the stores the user belongs to)
- **Human guide:** https://thecreators.company/docs/mcp

## Step 1: Discover

A request to `https://thecreators.company/mcp` without a token returns:

```http
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="mcp", resource_metadata="https://thecreators.company/.well-known/oauth-protected-resource/mcp"
```

Fetch the Protected Resource Metadata (RFC 9728):

```http
GET https://thecreators.company/.well-known/oauth-protected-resource/mcp
```

Its `authorization_servers[0]` is `https://thecreators.company`. Fetch that server's metadata (RFC 8414):

```http
GET https://thecreators.company/.well-known/oauth-authorization-server
```

It lists `authorization_endpoint`, `token_endpoint` and `registration_endpoint`. Use the values from the metadata rather than hard-coding them.

## Step 2: Register a client

Use dynamic client registration (RFC 7591). No account or API key is needed.

```http
POST https://thecreators.company/oauth/register
Content-Type: application/json

{
  "client_name": "Your Agent",
  "redirect_uris": ["http://127.0.0.1:33418/callback"]
}
```

The response includes a `client_id`. Clients are public (`token_endpoint_auth_method: none`), so there is no client secret. Registering a client creates no user account and grants no access on its own.

## Step 3: Get the user's approval

Run the OAuth 2.1 authorization code flow with PKCE (`S256` only):

1. Send the user to `https://thecreators.company/oauth/authorize` with `response_type=code`, your `client_id`, `redirect_uri`, `scope=mcp:use`, `state`, `code_challenge` and `code_challenge_method=S256`.
2. The user signs in to The Creators Company (or signs up) and approves your agent.
3. Exchange the returned `code` at `https://thecreators.company/oauth/token` with `grant_type=authorization_code`, your `client_id`, `redirect_uri` and `code_verifier`.

The token response contains an `access_token` and a `refresh_token`.

## Step 4: Call the API

Send the access token in the `Authorization` header. It is the only supported bearer method.

```http
POST https://thecreators.company/mcp
Authorization: Bearer <access_token>
Content-Type: application/json
Accept: application/json, text/event-stream

{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": {"name": "Your Agent", "version": "1.0.0"}}}
```

Then call `tools/list` to see what you can do.

## Step 5: Refresh, or start over

When the access token expires, use `grant_type=refresh_token` at the token endpoint. If that fails with `invalid_grant`, the user revoked your access or the refresh token expired: go back to Step 3.
