Skip to main content
Glama

Next.js MCP Server

by CoinCrew-AI

Next.js MCP Server

Model Context Protocol server built with Next.js and mcp-handler

Overview

This is a Next.js application that implements an MCP (Model Context Protocol) server using the Vercel MCP Adapter. It provides endpoints for AI assistants to interact with custom tools and resources.

Quick Start

  1. Install dependencies:
pnpm install
  1. Set up environment variables in .env.local:
REDIS_URL=redis://your-redis-url-here
  1. Run the development server:
pnpm dev
  1. The server will display the port it's running on (e.g., http://localhost:3005)

Available Tools

The server currently provides two example tools:

  • echo: Echoes a message back to the user
  • add: Adds two numbers together

To add more tools, edit app/api/mcp/[transport]/route.ts following the MCP TypeScript SDK documentation.

Testing the MCP Server

Using curl

# List available tools curl -X POST http://localhost:<PORT>/api/mcp/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","method":"tools/list","params":{},"id":1}' # Call the echo tool curl -X POST http://localhost:<PORT>/api/mcp/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"echo","arguments":{"message":"Hello!"}},"id":2}' # Call the add tool curl -X POST http://localhost:<PORT>/api/mcp/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"add","arguments":{"a":5,"b":3}},"id":3}' # SSE endpoint (for streaming connections) curl http://localhost:<PORT>/api/mcp/sse

Using the test client

# Test with SSE transport (requires server URL) node scripts/test-client.mjs http://localhost:<PORT> # Test with Streamable HTTP transport node scripts/test-streamable-http-client.mjs http://localhost:<PORT>

Note: The MCP endpoints are now organized under /api/mcp/ for better structure when integrating into existing Next.js applications.

Deployment 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, adjust maxDuration in app/[transport]/route.ts to 800 if using a Vercel Pro or Enterprise account
  • Deploy the Next.js MCP template
-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

A Model Context Protocol server built with Next.js that provides AI assistants with access to custom tools and resources. Includes example tools for echoing messages and performing mathematical operations, with support for both SSE and HTTP transports.

  1. Overview
    1. Quick Start
      1. Available Tools
        1. Testing the MCP Server
          1. Using curl
          2. Using the test client
        2. Deployment on Vercel

          Related MCP Servers

          • -
            security
            F
            license
            -
            quality
            A comprehensive Model Context Protocol server implementation that enables AI assistants to interact with file systems, databases, GitHub repositories, web resources, and system tools while maintaining security and control.
            Last updated -
            6
            1
          • -
            security
            F
            license
            -
            quality
            Enables real-time communication between applications and AI models using the Model Context Protocol, supporting features like custom tools and multiple transport options for Next.js applications.
            Last updated -
            30,445
            • Apple
          • -
            security
            A
            license
            -
            quality
            A sample implementation of a Model Context Protocol server using Next.js and the Vercel MCP Adapter, allowing developers to create AI assistants with custom tools and resources.
            Last updated -
            MIT License
          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol server that enables AI assistants to interact with ERPNext data and functionality, providing access to documents, reports, and CRUD operations via structured API calls.
            Last updated -
            2
            MIT License
            • 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/CoinCrew-AI/mcp-test'

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