You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: auth-for-mcp/xmcp-mcp-js/README.md
+44-8Lines changed: 44 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Example XMCP MCP Server with Auth0 Integration
2
2
3
3
This is a practical example of securing a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/docs) server
4
-
with Auth0 using the [XMCP](https://xmcp.dev/) framework.
4
+
with Auth0 using the [XMCP](https://xmcp.dev/) framework and the official [@xmcp-dev/auth0](https://xmcp.dev/docs/integrations/auth0) plugin.
5
5
6
6
## Available Tools
7
7
@@ -21,18 +21,54 @@ npm install
21
21
22
22
## Auth0 Tenant Setup
23
23
24
-
For detailed instructions on setting up your Auth0 tenant for MCP server integration, please refer to the [Auth0 Tenant Setup guide](https://github.com/auth0-samples/auth0-ai-samples/tree/main/auth-for-mcp/fastmcp-mcp-js/README.md#auth0-tenant-setup) in the FastMCP example.
24
+
The `@xmcp-dev/auth0` plugin requires the following Auth0 configuration:
# API identifier URL (must match the API resource created in Auth0)
44
+
AUDIENCE=http://localhost:3001/mcp
45
+
46
+
# MCP server base URL
47
+
BASE_URL=http://localhost:3001
48
+
49
+
# Machine-to-machine application credentials
50
+
CLIENT_ID=your_m2m_client_id
51
+
CLIENT_SECRET=your_m2m_client_secret
30
52
```
31
-
# Auth0 tenant domain
32
-
AUTH0_DOMAIN=example-tenant.us.auth0.com
33
-
# Auth0 API Identifier
34
-
AUTH0_AUDIENCE=http://localhost:3001/
35
-
```
53
+
54
+
## Permission Enforcement
55
+
56
+
Tools are **public by default**. Any authenticated user can access them.
57
+
58
+
To make a tool private, add a `tool:<tool-name>` permission in your Auth0 API settings:
59
+
60
+
1. Go to **Auth0 Dashboard** → **Applications** → **APIs** → Your API
61
+
2. Go to **Permissions** tab
62
+
3. Add permission: `tool:greet` (for a tool named "greet")
63
+
4. Assign the permission to users who should have access
64
+
65
+
The Auth0 xmcp plugin queries Auth0 Management API on each request:
66
+
67
+
1.**Check if permission exists** → queries `read:resource_servers` to see if `tool:<name>` is defined
68
+
2.**If permission exists** → queries `read:users` to verify the user has it assigned
69
+
3.**If permission does not exist** → tool is public, any authenticated user can access
70
+
71
+
> **Note**: If Management API calls fail, the secure default is to deny access. This ensures real-time permission verification rather than relying on potentially stale token claims.
0 commit comments