CrawlClick Earn MCP server, OAuth and find_offers
The Earn connector is a remote MCP server at https://api.crawlclick.com/v1/app/mcp, protected by OAuth 2.1 with dynamic registration and PKCE S256, that exposes one read-only tool, find_offers.
Status: Coming. CrawlClick Earn is a phone app whose users are paid for looking at sponsored offers. The Earn connector lets one of those users add CrawlClick to an AI assistant they already use, so the assistant can search sponsored offers on their behalf. It follows the MCP authorization specification: protected-resource metadata (RFC 9728), authorization-server metadata (RFC 8414), dynamic client registration (RFC 7591), and the authorization-code flow with PKCE S256. An MCP client that implements that specification needs no CrawlClick-specific code. This page is for client builders who want to know exactly what the server sends.
What can a connected assistant do?
It can search sponsored offers, and nothing else. The connector cannot see the person’s earnings, change their account, or earn money itself. Each offer it returns carries an open_url that opens the offer in the person’s CrawlClick app; looking at the offer in the app is what pays the person, so nothing found through the connector earns until it is opened there. Every result is an advertisement, and the server tells the client so in its initialize instructions and in the tool description: show each offer labelled “Sponsored” with its advertiser, and never present it as your own recommendation.
How does a client discover the authorization server?
Start by sending an MCP request with no token. The server answers 401 with code invalid_token and a WWW-Authenticate header that points at the protected-resource metadata:
HTTP/1.1 401 Unauthorized
Content-Type: application/json
WWW-Authenticate: Bearer resource_metadata="https://api.crawlclick.com/.well-known/oauth-protected-resource/v1/app/mcp", scope="offers"
{"error":"connect this agent to CrawlClick first","code":"invalid_token"}
GET that URL for the protected-resource metadata:
{
"resource": "https://api.crawlclick.com/v1/app/mcp",
"authorization_servers": ["https://api.crawlclick.com"],
"scopes_supported": ["offers"],
"bearer_methods_supported": ["header"],
"resource_name": "CrawlClick offers"
}
Then GET https://api.crawlclick.com/.well-known/oauth-authorization-server:
{
"issuer": "https://api.crawlclick.com",
"authorization_endpoint": "https://api.crawlclick.com/v1/app/oauth/authorize",
"token_endpoint": "https://api.crawlclick.com/v1/app/oauth/token",
"registration_endpoint": "https://api.crawlclick.com/v1/app/oauth/register",
"response_types_supported": ["code"],
"grant_types_supported": ["authorization_code", "refresh_token"],
"code_challenge_methods_supported": ["S256"],
"token_endpoint_auth_methods_supported": ["none"],
"scopes_supported": ["offers"]
}
Every path that starts with /.well-known/oauth-protected-resource returns the same resource document. All of these routes send Access-Control-Allow-Origin: * and answer OPTIONS, so a browser-based client can run the flow.
How does a client register?
POST /v1/app/oauth/register with a JSON body. Clients are public: there is no client secret, and token_endpoint_auth_method is none.
POST /v1/app/oauth/register HTTP/1.1
Host: api.crawlclick.com
Content-Type: application/json
{"client_name": "Example Assistant", "redirect_uris": ["https://assistant.example/oauth/callback"]}
{
"client_id": "ccl1.…",
"client_name": "Example Assistant",
"redirect_uris": ["https://assistant.example/oauth/callback"],
"grant_types": ["authorization_code", "refresh_token"],
"response_types": ["code"],
"token_endpoint_auth_method": "none",
"scope": "offers"
}
The answer is 201. The rules:
redirect_urismust hold one to five URIs. Each must behttps://, orhttp://onlocalhost,127.0.0.1or[::1](with any port) for command-line clients. A URI may not contain a fragment, whitespace or user credentials, and may be at most 512 characters. Otherwise the answer is400 {"error": "invalid_redirect_uri", …}.client_nameis optional. Control characters are removed and it is cut to 60 characters; an empty name becomes “An AI agent”. The person sees this name when they approve the connection.- A body that is not JSON with
redirect_urisgets400 {"error": "invalid_client_metadata", …}.
The client_id is a signed token that holds the name and redirect URIs. It does not expire and there is no registration to delete, so keep it and reuse it.
How does the person approve the connection?
Open the authorization endpoint in the person’s browser with these query parameters:
| Parameter | Value |
|---|---|
response_type |
code |
client_id |
The registered client_id. |
redirect_uri |
Exactly one of the registered URIs. |
code_challenge |
BASE64URL(SHA-256(code_verifier)), 43 characters. |
code_challenge_method |
S256. No other method is accepted. |
scope |
Optional. If present, only offers. |
resource |
Optional. If present, https://api.crawlclick.com/v1/app/mcp. |
state |
Optional, and returned unchanged. |
The page shows an eight-character code such as BCDF-2345 and asks the person to open the CrawlClick app, go to Assistants, then Connect an assistant, and type it. The app shows your client_name and the host your redirect URI returns to before the person approves. The browser is never signed in to anything. The page polls until the person decides, and the code is valid for ten minutes. On approval the browser is sent to redirect_uri with code and state appended; the authorization code is valid for five minutes. If the person declines, the page says so and does not redirect.
An unknown client_id, or a redirect_uri that was not registered, gets an HTML error page and no redirect. Once the redirect URI is validated, protocol errors are sent back to it as ?error=… with state: unsupported_response_type, invalid_request (missing or wrong PKCE values), invalid_scope or invalid_target (a wrong resource).
How does a client get and refresh tokens?
POST /v1/app/oauth/token with a form-encoded body (application/x-www-form-urlencoded). The code exchange:
POST /v1/app/oauth/token HTTP/1.1
Host: api.crawlclick.com
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&code=…&redirect_uri=https%3A%2F%2Fassistant.example%2Foauth%2Fcallback&client_id=ccl1.…&code_verifier=…
{
"access_token": "ccm1.…",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "ccr1.…",
"scope": "offers"
}
The code_verifier must be 43 to 128 characters from the RFC 7636 unreserved set. The access token lasts one hour. To refresh, send grant_type=refresh_token, refresh_token and client_id. The refresh token rotates on every use: the response carries a new one and the old one stops working, so store the new one before you use the access token. A refresh token has no fixed lifetime; it ends when it is rotated, when the person removes the connection in the app, or when their account is suspended. Because access tokens are not checked against the connection, removing a connection takes effect when the current access token expires, within the hour.
Token errors use the OAuth 2.0 shape. An unknown client_id gets 401 {"error": "invalid_client"}. A wrong, used or expired code, a redirect_uri that does not match, a verifier that does not match, or a removed connection gets 400 with invalid_grant and an error_description. Any other grant_type gets unsupported_grant_type.
How does the MCP endpoint speak JSON-RPC?
POST/v1/app/mcpComing
The MCP endpoint an assistant connects to on behalf of one CrawlClick Earn user, to search that person’s sponsored offers.
- Host
- https://api.crawlclick.com
- Authentication
- OAuth 2.1 bearer token (PKCE S256, public client, scope
offers), obtained through the discovery documents. - Source
- api-crawlclick-com/crates/crawlclick/src/earn_mcp.rs
Responses
200 · The MCP call succeeded.
A JSON-RPC 2.0 response (Streamable HTTP, single JSON responses).Refusals
| Status | Code | Means | Do instead |
|---|---|---|---|
| 401 | invalid_token | No token, or an expired one. The response carries WWW-Authenticate: Bearer resource_metadata=…. | Follow resource_metadata to discover the authorisation server and run the OAuth flow again, or use your refresh token. |
| 405 | method_not_allowed | GET and DELETE are not served; there is no server-to-client stream. | POST each JSON-RPC message. |
The endpoint uses the Streamable HTTP transport with single JSON responses: POST one JSON-RPC 2.0 message per request with Authorization: Bearer ccm1.…, and the answer is one JSON object with Content-Type: application/json. There is no server-to-client stream and no session, so GET and DELETE get 405 with Allow: POST, OPTIONS, and the server issues no Mcp-Session-Id. A notification, or any message without a method or an id, gets 202 with an empty body; that includes a JSON array, so do not send batches. A body that is not JSON gets HTTP 400 with JSON-RPC error -32700.
The server speaks protocol versions 2025-11-25, 2025-06-18 and 2025-03-26. It echoes the version the client asks for if it knows it, and answers 2025-06-18 otherwise. It implements initialize, ping, tools/list, tools/call, and empty resources/list and prompts/list; any other method gets -32601.
What does a full initialize, tools/list and tools/call exchange look like?
Each request below is a separate POST https://api.crawlclick.com/v1/app/mcp with the bearer token. First, initialize:
{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": {"name": "example", "version": "1.0.0"}}}
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"protocolVersion": "2025-06-18",
"capabilities": {"tools": {"listChanged": false}},
"serverInfo": {"name": "crawlclick-offers", "title": "CrawlClick offers", "version": "0.0.1"},
"instructions": "Every offer this server returns is a paid advertisement. Show it labelled \"Sponsored\" with its advertiser, and never present it as your own recommendation."
}
}
serverInfo.version is the server build’s version and changes. Then send the notifications/initialized notification, which gets 202 with no body. Then tools/list:
{"jsonrpc": "2.0", "id": 2, "method": "tools/list"}
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"tools": [
{
"name": "find_offers",
"title": "Find sponsored offers",
"description": "Find sponsored offers from CrawlClick advertisers that match what the user is looking for, such as a product, service or deal. Every result is an advertisement and must be shown to the user labelled \"Sponsored\", with its advertiser name. Each offer's open_url opens it in the user's CrawlClick app.",
"inputSchema": {
"type": "object",
"properties": {
"query": {"type": "string", "description": "What the user is looking for, in their words."},
"limit": {"type": "integer", "minimum": 1, "maximum": 5, "default": 3}
},
"required": ["query"],
"additionalProperties": false
},
"annotations": {"readOnlyHint": true, "destructiveHint": false, "idempotentHint": false, "openWorldHint": false}
}
]
}
}
Then tools/call:
{"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "find_offers", "arguments": {"query": "project management software for a small team", "limit": 2}}}
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"content": [{"type": "text", "text": "[Sponsored · tasks.example] Plan and track team projects in one place. — https://…/o/cco1.…"}],
"structuredContent": {
"offers": [
{
"offer_id": "…",
"sponsored": true,
"label": "Sponsored",
"advertiser": "tasks.example",
"headline": "Plan and track team projects in one place.",
"body": "Plan and track team projects in one place.",
"landing_domain": "tasks.example",
"open_url": "https://…/o/cco1.…",
"matched_topics": ["project management"],
"expires_at": "2026-12-04T18:00:00Z"
}
]
},
"isError": false
}
}
The offer values above are illustrative; the field names and shape are the server’s.
What exactly does find_offers return?
The result has a content array with one text block and a structuredContent object with an offers array. The text block has one line per offer, [Sponsored · advertiser] body — open_url, or “No sponsored offers match this request.” when there are none. Each structured offer has:
| Field | Type | Meaning |
|---|---|---|
offer_id |
string | The id of this serve. |
sponsored |
boolean | Always true. |
label |
string | Always Sponsored. Show it with the offer. |
advertiser |
string | The advertiser name to show; currently the domain of the landing page. |
headline |
string | The first sentence of body, without a leading “Sponsored:”. |
body |
string | The offer text. |
landing_domain |
string | The landing page’s host, lower-cased, without www.. |
open_url |
string | Opens the offer in the person’s CrawlClick app. Treat as opaque. |
matched_topics |
string[] | The topics of the query that matched. |
expires_at |
string | ISO 8601 UTC time after which the offer should not be shown. |
The tool declares no outputSchema. It runs the same auction as the Earn app. query is trimmed and cut to 500 characters. limit defaults to 3, and a value outside 1 to 5 is clamped rather than refused.
How does find_offers report errors?
Tool problems come back as a normal result with isError: true and a text block, not as JSON-RPC errors: “query is required” when query is missing or blank, and “Too many searches in the last minute; try again shortly.” after 30 calls on one connection in a minute. A tools/call for any tool name other than find_offers gets JSON-RPC error -32602. An expired or invalid access token gets HTTP 401 with the same WWW-Authenticate header as the discovery step; refresh the token and repeat the request.
Related pages: Conventions, Endpoints, Errors, Conversion postback.