MCP quickstart
The MCP authorization specification makes your MCP server an OAuth resource server and leaves issuing tokens to an authorization server. A resource server accepts access tokens, and an authorization server issues them. Timonier acts as the authorization server for your MCP server.
An assistant identifies itself with a Client ID Metadata Document, so you register nothing for it. The client ID is an HTTPS URL, and that URL serves a JSON document with the client's metadata. The format is an IETF draft, not a standard. People sign in on your app's sign-in page and approve the assistant on a consent screen. The assistant then gets a token bound to your MCP server's address.
This guide runs a sample MCP server on your machine and connects the MCP Inspector to it. The MCP Inspector (2.16.0) is the client we have tested.
Before you start
- Node.js
^22.23.4,^24.22.1or>=26.12.1. - A project in your operator dashboard. Steps 1 and 2 of the Next.js quickstart create one.
- An HTTPS host you control that can serve one JSON file publicly. Part 3 uses it. Any static file host works if it serves the file as step 7 describes: status 200,
application/jsonand no redirect. AlocalhostURL cannot work, because Timonier fetches the file from its own servers.
Part 1 — turn on assistant sign-in
1. Create an app
From the project's apps list, create a new app. Fill in Display name, Slug and Redirect URI 1. The form requires one redirect URI, for example http://localhost:3000/callback. Confirm, then save your credentials.
2. Set your server's address
Open the app's page. In the Assistant sign-in card, set MCP server resource URI to http://localhost:3007/mcp, then click Save. The status reads On.
3. Copy the issuer
Open the app's Integration tab and copy Issuer. Step 5 needs it.
Part 2 — run the sample server
4. Save the server
Save this as server.mjs:
// Sample MCP server for the Timonier MCP quickstart: protected-resource metadata,
// a 401 challenge, EdDSA access-token validation, and one tool over Streamable HTTP.
import from "node:http";
import from "node:crypto";
const ISSUER = process.env.TIMONIER_ISSUER;
if (!ISSUER
error"Set TIMONIER_ISSUER to your app's issuer."
exit1
const PORT = 3007;
const ORIGIN = `http://localhost:${PORT}`;
const RESOURCE = `${ORIGIN}/mcp`;
const METADATA_PATH = "/.well-known/oauth-protected-resource/mcp";
const METADATA_URL = `${ORIGIN}${METADATA_PATH}`;
const keys = new Map();
const b64 = (s) => Buffer.from(s, "base64url");
async function keyFor(kid
if!has
const res = await fetch`${ISSUER}/.well-known/jwks.json`
if! throw new Error`jwks ${res.status}`
const keys jwks = awaitjson
clear
forconst jwk of
if === "OKP" && === "Ed25519"
set createPublicKey "jwk"
returnget
async function validate(header
const m = /^Bearer (\S+)$/exec ?? ""
if === null return null
consth p s extra =1split"."
if === undefined || extra !== undefined return null
try
const head = JSONparseb64toString
if !== "EdDSA" return null
const key = await keyFor
if === undefined || !verifynullfrom`${h}.${p}` b64 return null
const claims = JSONparseb64toString
const accepted =
=== ISSUER &&
=== RESOURCE &&
typeof === "number" &&
isFinite &&
>now / 1000
return accepted ? claims : null
catch
return null
function send(res, status, body, headers =
writeHead "Content-Type" "application/json" ...
end === undefined ? undefined : JSONstringify
function rpc(claims, msg
const reply =result => "2.0"
switch
case "initialize"
return reply
"2025-06-18"
"timonier-sample-mcp" "0.0.1"
case "tools/list"
return reply
"whoami"
"Returns the signed-in subject and the client that holds the token."
"object"
case "tools/call"
if !== "whoami"
return "2.0" -32602 "unknown tool"
return reply
"text" JSONstringify
default
return "2.0" -32601 "method not found"
const readBody = async (req) =>
const chunks =
for awaitconst c ofpush
returnconcattoString
const server = createServer(async (req, res) =>
let
try
path = new URL ORIGIN
catch
return send 400 "bad_request"
if === METADATA_PATH
return send 200
RESOURCE
ISSUER
"header"
if !== "/mcp" return send 404 "not_found"
if !== undefined return send 403 "forbidden_origin"
if !== "POST" return send 405 "method_not_allowed" "POST"
const claims = await validate
if === null
return send 401 "invalid_token"
"WWW-Authenticate" `Bearer resource_metadata="${METADATA_URL}"`
let
try
msg = JSONparseawait readBody
catch
return send 400 "2.0" null -32700 "parse error"
iftypeof msg !== "object" || msg === null ||isArray || typeof !== "string"
return send 400 "2.0" null -32600 "invalid request"
if === undefined return send 202
return send 200 rpc
server.listen(PORT, "127.0.0.1", () =>
log`Listening on ${ORIGIN}`
5. Start it
Put the issuer from step 3 in place of the placeholder and start the server. Leave it running.
TIMONIER_ISSUER='<your-issuer>' node server.mjs6. Check the challenge
In a second terminal, call the server without a token:
curl -i -X POST http://localhost:3007/mcp
The response is 401 with the header WWW-Authenticate: Bearer resource_metadata="http://localhost:3007/.well-known/oauth-protected-resource/mcp". An MCP client reads that URL to find your platform.
The sample checks requests to /mcp in two ways. A request that carries an Origin header gets 403. A request without Origin, such as curl's, still needs a valid bearer token. The protected-resource metadata route answers without these checks. The MCP Streamable HTTP transport requires a server to validate Origin to prevent DNS rebinding attacks.
Part 3 — publish the Inspector's metadata document
7. Host the document
Save this JSON and serve it from an HTTPS URL you control. Put that URL in place of the placeholder:
{
"client_id": "<your-metadata-url>",
"client_name": "MCP Inspector",
"redirect_uris": ["http://localhost:6274/oauth/callback"],
"grant_types": ["authorization_code", "refresh_token"],
"response_types": ["code"],
"token_endpoint_auth_method": "none"
}
Timonier fetches the document from that URL, and it refuses the document unless all of these hold:
- The URL uses HTTPS, its host is a domain name, and its path is not
/. - The response has status 200 and
Content-Type: application/json. - The response is not a redirect.
- The document is at most 5,120 bytes.
client_idin the document equals the URL it was fetched from.
Timonier caches the document for at least 5 minutes, and for 1 hour when the response has no
Cache-Control: max-age. A change you make to the document may take that long to show up.
Check that the URL answers correctly:
curl -sS -o /dev/null -w '%{http_code} %{content_type}\n' '<your-metadata-url>'
Expect 200 application/json. curl may print media-type parameters, for example application/json; charset=utf-8, and that is fine.
Part 4 — connect the MCP Inspector
8. Start the Inspector
npx @modelcontextprotocol/inspector@2.16.0 --web
The Inspector prints a link that ends in ?MCP_INSPECTOR_API_TOKEN= and a token. Open it with localhost in place of 127.0.0.1, so the address matches the redirect_uris in your document.
9. Add your server
Open Client settings, then OAuth Client ID Metadata Document. Tick Use Client ID Metadata Document, enter <your-metadata-url>, and click Close.
Click Add Servers, then + Add manually, and fill in:
- Server ID —
sample - Transport —
streamable-http - URL —
http://localhost:3007/mcp
Click Add.
10. Sign in and approve
Turn on the connect switch for sample. The Inspector sends you to your app's sign-in page, which names MCP Inspector. Enter your email, then open the emailed link in the same browser and click Continue sign-in.
The consent page warns that sign-in returns to a program on this device. Click Allow access.
11. Call the tool
In the Inspector, open Tools, select whoami, and click Execute Tool. The result shows sub, the person's ID, and client_id, your metadata URL.
12. See the assistant in the dashboard
Open Assistants in the project navigation. The list shows MCP Inspector with one connected person.
Going to production
- Set MCP server resource URI to your server's
httpsaddress. - Validate
iss,audandexpon every token, as the sample does. Timonier signs access tokens with EdDSA and publishes the keys at{issuer}/.well-known/jwks.json. - Access tokens last 60 seconds.