Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/mcp/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
AUTH0_DOMAIN=your-tenant.region.auth0.com
AUTH0_AUDIENCE=http://localhost:3000
9 changes: 9 additions & 0 deletions examples/mcp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# MCP Example specific ignores

# Keep the .env.example file for this example
!.env.example

# vercel
.vercel

next-env.d.ts
52 changes: 52 additions & 0 deletions examples/mcp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Example Nextjs MCP Server with Auth0 Integration

This is a practical example of securing a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/docs) server
with Auth0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel it might be helpful to include a bit more detail on how the application is being secured, particularly highlighting the key aspects of the security implementation.


## Install dependencies

- Run `pnpm install:examples` from the root to install dependencies

## Auth0 Tenant Setup

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/auth0-auth-js/blob/main/examples/example-fastmcp-mcp/README.md#auth0-tenant-setup).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link 404s

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link should be available once auth0/auth0-auth-js#45 merges in

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is resolved now that the above PR is merged in


## Configuration

Rename `.env.example` to `.env` and configure the domain and audience:

```
# Auth0 tenant domain
AUTH0_DOMAIN=example-tenant.us.auth0.com
# Auth0 API Identifier
AUTH0_AUDIENCE=http://localhost:3000
```

With the configuration in place, the example can be started by running:

## Running the Server

For development with hot reload:

```bash
pnpm dev
```

Or build and run in production mode:

```bash
pnpm build
pnpm start
```

## Testing

Use an MCP client like [MCP Inspector](https://github.com/modelcontextprotocol/inspector) to test your server interactively:

```bash
npx @modelcontextprotocol/inspector
```

The server will start up and the UI will be accessible at http://localhost:6274.

In the MCP Inspector, select `Streamable HTTP` as the `Transport Type` and enter `http://localhost:3000/mcp` as the URL.
5 changes: 5 additions & 0 deletions examples/mcp/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {};

export default nextConfig;
30 changes: 30 additions & 0 deletions examples/mcp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "mcp",
"version": "0.1.0-beta.1",
"description": "Example implementation of a MCP server using Next.js with Auth0",
"scripts": {
"dev": "next dev --turbo",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@auth0/auth0-api-js": "^1.0.2",
"@auth0/nextjs-auth0": "^4.5.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see @auth0/nextjs-auth0 used in this example, am i missing anything ?

"@modelcontextprotocol/sdk": "^1.0.0",
"dotenv": "^17.2.1",
"mcp-handler": "^1.0.0",
"next": "^15.2.4",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"zod": "^3"
},
"devDependencies": {
"@types/node": "^22",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "^15.2.4",
"typescript": "^5"
}
}
Loading