fastmcp/examples/auth/auth0_mcp/client.py
vijaydeepsinha 654335607c
Fix-issue-4284 : Add Auth0MCPProvider for Auth0 Auth for MCP (#4411)
* Add Auth0MCPProvider for Auth0 Auth for MCP

* Document Auth0 MCP provider integration

* Add Auth0MCPProvider scope and auth rejection tests

Cover permissions-based required_scopes enforcement and unauthenticated MCP 401 responses.

* fixed documentation

* Narrow Auth0 docs to integration guide only

* Fix Auth0 provider: use httpx2 instead of httpx

httpx is a dev-only transitive dependency in this repo; runtime installs
declare httpx2 exclusively. The module-level 'import httpx' in auth0.py
broke import on a clean install of fastmcp or fastmcp-slim[server].

---------

Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2026-07-18 21:15:02 -04:00

21 lines
488 B
Python

"""Auth0 Auth for MCP client example."""
import asyncio
from fastmcp import Client
from fastmcp.client.auth import OAuth
auth = OAuth(
additional_client_metadata={"token_endpoint_auth_method": "none"},
callback_host="127.0.0.1",
)
async def main() -> None:
async with Client("http://127.0.0.1:8000/mcp", auth=auth) as client:
result = await client.call_tool("echo", {"message": "hello"})
print(result)
if __name__ == "__main__":
asyncio.run(main())