Next.js MCP Server

Integrations
  • Allows integration of MCP servers into Next.js applications with specific route handling capabilities.

  • Enables Server-Sent Events (SSE) transport for MCP functionality when deployed on Vercel.

  • Provides TypeScript SDK support for defining tools, prompts, and resources in the MCP server implementation.

Headless MCP-use (from Registry) with Next.js

Uses @vercel/mcp-adapter with a configurable MCP registry

Deployed URL

This application is deployed at: https://nextjs-mcp-use.vercel.app

Features

  • MCP Registry: Configure multiple MCP servers in a single JSON file
  • GitHub Actions: Test and monitor your API endpoints with scheduled and manual workflows
  • Error Handling: Graceful handling of timeouts and connection failures
  • Environment Variables: Configure environment variables for each MCP server

MCP Registry

The MCP registry is a JSON configuration file that stores information about all available MCP servers. Each server can be enabled or disabled, and can have its own environment variables.

The registry is located at config/mcp-registry.json and has the following structure:

{ "server-name": { "url": "http://localhost:3002/sse", "enabled": true, "env": { "API_KEY": "your-api-key" } }, "another-server": { "url": "https://example.com/sse", "enabled": false } }

Usage

This sample app uses the Vercel MCP Adapter that allows you to drop in an MCP server on a group of routes in any Next.js project.

Update app/[transport]/route.ts with your tools, prompts, and resources following the MCP TypeScript SDK documentation.

API Endpoints

  • Chat API: /api/chat - Streaming chat endpoint
  • Completions API: /api/completions - Non-streaming chat completions endpoint

Testing the API

You can test the API endpoints using the provided test script:

# Test the chat endpoint npm run test:chat -- --message "Your message here" # Test the completions endpoint npm run test:completions -- --message "Your message here" # Test with a custom URL npm run test:chat -- --url http://localhost:3000/api/chat --message "Your message here"

GitHub Actions

This project includes GitHub Actions workflows for testing and monitoring the API endpoints. See the .github/workflows/README.md file for more information.

Notes for running on Vercel

  • To use the SSE transport, 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/route.ts and adjust maxDuration to 800 if you using a Vercel Pro or Enterprise account
  • Deploy the Next.js MCP template

Sample Client

  • scripts/test-client.mjs contains a sample client to try invocations.
node scripts/test-client.mjs https://nextjs-mcp-use.vercel.app
-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

A sample MCP server implementation for Next.js projects that uses the Vercel MCP Adapter to handle protocol requests across different transport methods.

  1. Deployed URL
    1. Features
      1. MCP Registry
        1. Usage
          1. API Endpoints
          2. Testing the API
        2. GitHub Actions
          1. Notes for running on Vercel
            1. Sample Client

              Related MCP Servers

              • -
                security
                A
                license
                -
                quality
                MCP Server for the Perplexity API.
                Last updated -
                50
                Python
                MIT License
                • Linux
                • Apple
              • A
                security
                A
                license
                A
                quality
                An MCP server that provides tools for interacting with Vercel API, enabling management of deployments, DNS records, domains, projects, and environment variables through natural language.
                Last updated -
                7
                65
                3
                TypeScript
                MIT License
              • -
                security
                A
                license
                -
                quality
                An MCP server that enables fetching web content using the Node.js undici library, supporting various HTTP methods, content formats, and request configurations.
                Last updated -
                66
                8
                TypeScript
                MIT License
                • Apple
                • Linux
              • A
                security
                F
                license
                A
                quality
                An MCP server implementation that enables interaction with the Unstructured API, providing tools to list, create, update, and manage sources, destinations, and workflows.
                Last updated -
                39
                26
                • Apple

              View all related MCP servers

              MCP directory API

              We provide all the information about MCP servers via our MCP API.

              curl -X GET 'https://glama.ai/api/mcp/v1/servers/cameronking4/nextjs-mcp-use'

              If you have feedback or need assistance with the MCP directory API, please join our Discord server