Skip to content

Commit de3634d

Browse files
authored
Merge pull request #72 from Sambego/feature/xmcp-auth0-plugin
Feature/xmcp auth0 plugin
2 parents cf5bfc5 + e95853a commit de3634d

File tree

22 files changed

+3548
-10863
lines changed

22 files changed

+3548
-10863
lines changed
Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
AUTH0_DOMAIN=
2-
AUTH0_AUDIENCE=
3-
PORT=3001
4-
MCP_SERVER_URL=http://localhost:3001
1+
# Auth0 Configuration for @xmcp-dev/auth0 plugin
2+
# See: https://xmcp.dev/docs/integrations/auth0
3+
4+
# Auth0 tenant domain (format: <tenant>.<region>.auth0.com)
5+
DOMAIN=""
6+
7+
# API identifier URL (must match the API resource created in Auth0)
8+
AUDIENCE=""
9+
10+
# MCP server base URL
11+
BASE_URL="http://localhost:3001"
12+
PORT="3001"
13+
14+
# Machine-to-machine application credentials
15+
CLIENT_ID=""
16+
CLIENT_SECRET=""
17+
18+
# Scopes (space-separated): eg: "tool:whoami tool:greet"
19+
SCOPES=""

auth-for-mcp/xmcp-mcp-js/README.md

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Example XMCP MCP Server with Auth0 Integration
22

33
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.
55

66
## Available Tools
77

@@ -21,18 +21,54 @@ npm install
2121

2222
## Auth0 Tenant Setup
2323

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:
25+
26+
1. **Enable Dynamic Client Registration**: In Auth0 Dashboard → Settings → Advanced, enable "OIDC Dynamic Application Registration"
27+
2. **Enable Resource Parameter Support**: In the same location, activate "Resource Parameter Compatibility Profile"
28+
3. **Promote Database Connection**: Promote your database connection to work with third-party clients
29+
4. **Create API Resource**: Create an API resource with an identifier matching your server URL
30+
5. **Set Default Audience**: Set the API identifier as the default audience in general settings
31+
6. **Create M2M Application**: Create a machine-to-machine application and save its Domain, Client ID, and Client Secret
32+
33+
For detailed instructions, see the [xMCP Auth0 Integration guide](https://xmcp.dev/docs/integrations/auth0).
2534

2635
## Configuration
2736

28-
Rename `.env.example` to `.env` and configure the domain and audience:
37+
Rename `.env.example` to `.env` and configure the following environment variables:
2938

39+
```bash
40+
# Auth0 tenant domain (format: <tenant>.<region>.auth0.com)
41+
DOMAIN=example-tenant.us.auth0.com
42+
43+
# 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
3052
```
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.
3672
3773
## Running the Server
3874

0 commit comments

Comments
 (0)