Agent SaaS Starter
Guides

MCP server

Protected-resource discovery, OAuth challenges, and tool authorization.

The endpoint is MCP_PUBLIC_URL/mcp and uses MCP Streamable HTTP. It targets the stable 2025-11-25 revision and negotiates the compatible 2025 revisions used by existing clients. Its protected-resource metadata is available at both:

  • /.well-known/oauth-protected-resource
  • /.well-known/oauth-protected-resource/mcp

The metadata points clients to AUTH_ISSUER. Unauthenticated MCP requests return a WWW-Authenticate challenge containing resource_metadata. Access tokens must have the MCP URL as their audience and include project:read.

Example tool

get_random_number is the only tool. It calls GET /api/v1/random-number with the OAuth bearer token and returns { "number": 42 } (an integer from 0 through 100). The API verifies the token and current project membership. No identity or credentials are returned by the tool.

Its OAuth scheme appears in both the top-level securitySchemes field and _meta.securitySchemes for client compatibility. Tool-level authentication errors also include _meta["mcp/www_authenticate"].

Concurrency model

The server runs on Tokio because remote Streamable HTTP is a many-client service with network I/O and cancellation. Tool discovery is static and cheap; tool execution is isolated behind the handler and the process uses a cancellation token for graceful shutdown.

On this page