Verifier-only auth with base_url advertises a resource_metadata URL that FastMCP does not serve
What happened?
I configured token verifiers without an authorization server and set base_url. The 401 on /mcp then carries WWW-Authenticate: Bearer resource_metadata="<base_url>/.well-known/oauth-protected-resource/mcp", and a GET on that URL returns 404. The app has no .well-known route at all, which sets this apart from the path mismatch in #1685. MultiAuth(verifiers=[...], base_url=...) and a bare JWTVerifier(..., base_url=...) passed as auth= behave the same way.
The docs describe this setup as serving no metadata: "Without a server, no OAuth routes or metadata are served." (Verifiers Only). I expected the challenge to leave out resource_metadata here, as it does when base_url is unset. A fix with a regression test is ready; I will open the PR against this issue.
Example Code
# /// script
# requires-python = ">=3.10"
# dependencies = ["fastmcp==4.0.10"]
# ///
import asyncio
import fastmcp
import httpx2
from fastmcp import FastMCP
from fastmcp.server.auth import MultiAuth
from fastmcp.server.auth.providers.jwt import StaticTokenVerifier
HOST = "https://mcp.example.com"
METADATA = "/.well-known/oauth-protected-resource/mcp"
async def probe(base_url: str | None) -> None:
verifier = StaticTokenVerifier(tokens={"secret": {"client_id": "demo"}})
auth = MultiAuth(verifiers=[verifier], base_url=base_url)
app = FastMCP("demo", auth=auth).http_app(path="/mcp")
transport = httpx2.ASGITransport(app=app)
async with httpx2.AsyncClient(transport=transport, base_url=HOST) as http:
response = await http.post("/mcp", json={})
challenge = response.headers["www-authenticate"]
metadata = await http.get(METADATA)
print(f"base_url={base_url}")
print(f" POST /mcp -> {response.status_code}, WWW-Authenticate: {challenge}")
print(f" GET {METADATA} -> {metadata.status_code}")
print(f"fastmcp {fastmcp.__version__}")
asyncio.run(probe(HOST))
asyncio.run(probe(None))Output:
fastmcp 4.0.10
base_url=https://mcp.example.com
POST /mcp -> 401, WWW-Authenticate: Bearer resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource/mcp"
GET /.well-known/oauth-protected-resource/mcp -> 404
base_url=None
POST /mcp -> 401, WWW-Authenticate: Bearer
GET /.well-known/oauth-protected-resource/mcp -> 404Main at b67c66eb prints the same.
Version Information
FastMCP version: 4.0.10
MCP version: 2.2.0
Python version: 3.14.0
Platform: Windows-11-10.0.26200-SP0Source: PrefectHQ/fastmcp