published fresh until

How should my MCP server handle user identity and auth?

Summary When an HTTP MCP server handles private user data, verify bearer authorization on every request and derive identity server-side. Our recommendation: keep authentication out of tool arguments, check access to model-supplied resource IDs, scope data in code and the database, and redact logs.

Not for deploying MCP with OAuth on Workers; see remote-mcp-server-cloudflare-workers

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

You are writing an MCP server that many people use with their own private data. Our recommendation: keep authentication out of the tool surface; treat model-supplied IDs as requests to access a resource, and check that access server-side.

What the source says

The following requirements come from the MCP drafts and PostgreSQL documentation opened on 2026-11-27; implementation choices below are labelled as our advice.

1. Verify each request. For HTTP authorization, clients must send authorization in the Authorization header on every request; servers must validate that the token is intended for them (authorization draft). Servers implementing authorization must verify all inbound requests. Possession of a state handle must not count as authentication; servers should bind handles to the authenticated user, deriving the user ID from the validated token, and reject handles presented by another principal (security best practices draft). Our advice: derive user, tenant and permissions server-side and pass tools an already-authenticated context; authorize any resource or workspace ID against that context. 2. Scope reads and writes at the database layer. Our advice: use row-level policies alongside application permission checks. In PostgreSQL, enabling row security without a policy denies normal row access. Superusers and roles with BYPASSRLS always bypass row security; owners normally bypass it but can opt into it with FORCE ROW LEVEL SECURITY (row security docs). Our advice: review the application's database role before relying on these policies. 3. Our recommendation: keep tool results minimal. Return only the fields a task needs. 4. Our recommendation: redact logs. Allowlist the fields you need and exclude authentication material from tool-input, tool-output and request logs.

How to describe it to your agent

Our suggested review prompt:

Review our MCP server tools. Keep user identity, tenant identity and tokens out of authentication parameters on tools. For HTTP authorization, validate the bearer token on every request in middleware, derive identity server-side and pass a context object to tools. Authorize any resource or workspace ID against that identity. Add database policies that fail closed and keep an application-level permission check. Return only the fields a task needs. Redact tool inputs and outputs in logs. List any tool argument the model could use to choose another user's data.

Mistakes to check

Our recommended checks:

  • Accepting a resource or workspace ID without checking the caller's access.
  • Logging raw tool arguments and results without a redaction policy.
  • Relying on RLS without checking bypass roles or application permissions.

Limits

This is source-based guidance with our own recommendations, not a security audit; nothing was run. For hosting and OAuth setup see the thread on running a remote MCP server on Cloudflare Workers.

Sources

Our result-minimisation and logging recommendations above are design advice, not requirements attributed to these pages.

Started from a post by @Street_Inevitable_77, packaged by the editor. Original post

Subjects

More in context management

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How should my MCP server handle user identity and auth?
Summary: When an HTTP MCP server handles private user data, verify bearer authorization on every request and derive identity server-side. Our recommendation: keep authentication out of tool arguments, check access to model-supplied resource IDs, scope data in code and the database, and redact logs.
Copy for agent
get the whatworks thread mcp-server-auth-never-a-tool-argument and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread mcp-server-auth-never-a-tool-argument
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks