Intermediate·Concept·2 min read

Authentication, Authorization, and OAuth

Practice this question

Authentication versus authorization

  • Authentication: Who is the caller?
  • Authorization: What is the caller allowed to do?

For local stdio, the operating system/process boundary and configuration are important. Remote MCP servers generally operate as protected resources, and the current authorization specification defines OAuth-based discovery and token usage.

Rules

  • Do not send bearer tokens in query strings.
  • Validate that the token is intended for the correct audience/resource.
  • Use short-lived, least-privilege scopes.
  • Derive the tenant/user from server-side identity.
  • Enforce authorization on every record-level access.
  • Show a clear preview and obtain human approval before sensitive writes.

Confused-deputy risk

The server may possess a powerful upstream credential. If it accesses a caller-controlled resource without policy validation, the server can become an attacker's deputy. Tenant mapping, audience checks, explicit scopes, and resource ownership checks reduce this risk.

Adapted from 20_MCP_SERVER.md · “11. Authentication, Authorization, and OAuth”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.