-
Notifications
You must be signed in to change notification settings - Fork 432
Add MCP Server example #2299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add MCP Server example #2299
Changes from all commits
0398cb5
a7a9ef7
546e8fa
e85c315
9e07ae4
96366f2
06e9dea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
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 |
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. | ||
|
||
## 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). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This link 404s There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
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; |
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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see |
||
"@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" | ||
} | ||
} |
There was a problem hiding this comment.
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.