Example MCP Server built on Next.js

by MarkArmsrong

331 downloads
Not rated
GitHub

About

This is a template for building Model Context Protocol (MCP) servers using Next.js, designed for serverless deployment on Vercel. It provides scaffolding for tools, prompts, and resources, with an SSE endpoint and Redis integration.

Details

Author
MarkArmsrong
Downloads
331
Categories
Other

- Built on Next.js for serverless deployment on Vercel
- Includes an SSE route for MCP communication
- Requires Redis for state persistence
- Supports custom tools, prompts, and resources via MCP SDK
- Sample client script for testing invocations

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Example MCP Server built on Next.js
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Update app/mcp.ts with your tools, prompts, and resources following the MCP TypeScript SDK documentation. Deploy on Vercel with a Redis instance attached via process.env.REDIS_URL and Fluid compute enabled. A sample client script (scripts/test-client.mjs) is included for testing invocations.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "example mcp server built on next.js": {
            "mcp-for-nextjs": {
                "command": "node",
                "args": [
                    "scripts/test-client.mjs",
                    "https://mcp-for-next-js.vercel.app"
                ]
            }
        }
    }
}

McpServers

{
    "mcp-for-nextjs": {
        "command": "node",
        "args": [
            "scripts/test-client.mjs",
            "https://mcp-for-next-js.vercel.app"
        ]
    }
}

Example MCP Server built on Next.js

Usage

Update app/mcp.ts with your tools, prompts, and resources following the MCP TypeScript SDK documentation.

Notes for running on Vercel

- Requires a Redis attached to the project under process.env.REDIS_URL
- Make sure you have Fluid compute enabled for efficient execution
- After enabling Fluid compute, open app/sse/route.ts and adjust max duration to 800 if you using a Vercel Pro or Enterprise account
- Deploy the Next.js MCP template

Sample Client

script/test-client.mjs contains a sample client to try invocations.

node scripts/test-client.mjs https://mcp-for-next-js.vercel.app
No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.