MCP invalid_token audience: protected resource metadata resource must equal server URL
The resource field in your protected resource metadata must equal the MCP URL users enter, path included. Fix audience and invalid_token errors.
The resource value in your protected resource metadata must be exactly the URL users enter for the MCP server, including the path, for example https://mcp.acme.example/mcp. Claude and ChatGPT copy it into the token audience, so a mismatch can lead to tokens your server rejects as invalid_token.
What you see
- A scan reports
auth.resource-mismatch: "resource is X, server URL is Y". - Sign-in completes, then the first MCP call returns 401 with
error="invalid_token". Whether a given client shows that text to the user is not verified here. - Your token validation logs show an audience that does not match what the server expects.
Why it happens
The MCP authorization spec uses the RFC 8707 resource parameter so tokens are bound to one server. The client takes resource from your metadata and sends it to the authorization server, which puts it in the token's aud. If your metadata says https://mcp.acme.example but your validator expects https://mcp.acme.example/mcp, or the reverse, valid tokens look wrong. Trailing slashes, http versus https, and a leftover staging hostname are the usual culprits.
Check it yourself
curl -s https://mcp.acme.example/.well-known/oauth-protected-resource/mcp | jq .resource
Compare the output character by character with the URL you give users. The scanner compares with a tolerant URL comparison, but clients may not be as forgiving, so make them identical.
To see the audience of an issued token (JWT only):
echo "$TOKEN" | cut -d. -f2 | base64 -d 2>/dev/null | jq '{aud, iss}'
Fix
Generate resource from one constant that your validator also uses:
const RESOURCE = "https://mcp.acme.example/mcp";
app.get("/.well-known/oauth-protected-resource/mcp", (_req, res) =>
res.json({ resource: RESOURCE, authorization_servers: ["https://auth.acme.example"] })
);
function validate(claims: { aud: string | string[] }) {
const aud = Array.isArray(claims.aud) ? claims.aud : [claims.aud];
if (!aud.includes(RESOURCE)) throw new Error("invalid_token");
}
Make sure your authorization server accepts resource and copies it into aud.
Verify
Re-run the curl check, complete a new sign-in, decode the issued token and confirm aud equals the same string. Then call tools/list with that token and expect 200.
Which clients care
The rule lists Claude and ChatGPT, and states both copy resource into the token audience.
Source
Claude authentication docs: https://claude.com/docs/connectors/building/authentication
Run a free scan at https://mcpshipyard.com/scan to check every rule at once.
Check every rule at once
A free scan runs this check and the other 152 against your live URL.
Related fixes
- Add Client ID Metadata Documents (CIMD) next to Dynamic Client Registration
- API key or token in the MCP server URL (?key=): why it fails and how to fix
- ChatGPT MCP: dynamic client registration not supported (CIMD or DCR required)
- Claude says "Couldn't reach the MCP server": missing protected resource metadata