Nexus MCP server

AI gateway that aggregates multiple MCP servers and LLM providers through a unified HTTP interface with JWT authentication, rate limiting, and tool discovery for centralized AI resource management.
Back to servers
Setup instructions
Provider
Grafbase
Release date
Aug 19, 2025
Language
Python
Stats
323 stars

Nexus is a powerful MCP (Model Context Protocol) router that allows you to connect multiple MCP servers, APIs, and LLM providers through a unified endpoint. It provides a centralized way to aggregate, govern, and control your entire AI stack with support for various protocols and LLM providers.

Installation

Quick Install (Linux/Windows (WSL)/macOS)

curl -fsSL https://nexusrouter.com/install | bash

Docker

Pull the latest image:

docker pull ghcr.io/grafbase/nexus:latest

For stable or specific versions:

docker pull ghcr.io/grafbase/nexus:stable
# or
docker pull ghcr.io/grafbase/nexus:X.Y.Z

Build from Source

git clone https://github.com/grafbase/nexus
cd nexus
cargo build --release

Running Nexus

Using the Binary

nexus

Using Docker

docker run -p 8000:8000 -v /path/to/config:/etc/nexus.toml ghcr.io/grafbase/nexus:latest

Docker Compose Example

services:
  nexus:
    image: ghcr.io/grafbase/nexus:latest
    ports:
      - "8000:8000"
    volumes:
      - ./nexus.toml:/etc/nexus.toml
    environment:
      - GITHUB_TOKEN=${GITHUB_TOKEN}
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
      interval: 30s
      timeout: 10s
      retries: 3

Configuration

Create a nexus.toml file to configure Nexus:

# LLM Provider configuration
[llm.providers.openai]
type = "openai"
api_key = "{{ env.OPENAI_API_KEY }}"
forward_token = true

# Model configuration (at least one model required per provider)
[llm.providers.openai.models.gpt-4]
[llm.providers.openai.models.gpt-3-5-turbo]

[llm.providers.anthropic]
type = "anthropic"
api_key = "{{ env.ANTHROPIC_API_KEY }}"

[llm.providers.anthropic.models.claude-3-5-sonnet-20241022]

# MCP Server configuration
[mcp.servers.github]
url = "https://api.githubcopilot.com/mcp/"
auth.token = "{{ env.GITHUB_TOKEN }}"

[mcp.servers.filesystem]
cmd = ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/Users/YOUR_USERNAME/Desktop"]

[mcp.servers.python_server]
cmd = ["python", "-m", "mcp_server"]
env = { PYTHONPATH = "/opt/mcp" }
cwd = "/workspace"

Server Configuration

  • server.listen_address: The address and port Nexus will listen on (default: 127.0.0.1:8000)
  • server.health.enabled: Enable health endpoint (default: true)
  • server.health.path: Health check endpoint path (default: /health)

MCP Server Types

Nexus supports three types of MCP servers:

  1. STDIO Servers: Launch local processes that communicate via standard input/output

    [mcp.servers.my_tool]
    cmd = ["path/to/executable", "--arg1", "--arg2"]
    env = { DEBUG = "1", API_KEY = "{{ env.MY_API_KEY }}" }
    cwd = "/path/to/working/directory"
    stderr = "inherit"  # Show in console
    
  2. SSE Servers: Connect to Server-Sent Events endpoints

    [mcp.servers.my_sse_server]
    protocol = "sse"
    url = "http://example.com/sse"
    message_url = "http://example.com/messages"  # Optional
    
  3. HTTP Servers: Connect to streamable HTTP endpoints

    [mcp.servers.my_http_server]
    protocol = "streamable-http"
    url = "https://api.example.com/mcp"
    

Authentication

Add service token authentication to any server:

[mcp.servers.my_server.auth]
token = "your-token-here"
# Or use environment variables
token = "{{ env.MY_API_TOKEN }}"

OAuth2 Authentication

Configure OAuth2 authentication to protect your Nexus endpoints:

[server.oauth]
url = "https://your-oauth-provider.com/.well-known/jwks.json"
poll_interval = "5m"
expected_issuer = "https://your-oauth-provider.com"
expected_audience = "your-service-audience"

[server.oauth.protected_resource]
resource = "https://your-nexus-instance.com"
authorization_servers = ["https://your-oauth-provider.com"]

Rate Limiting

Nexus supports comprehensive rate limiting:

# Global rate limiting configuration
[server.rate_limits]
enabled = true

# Storage backend configuration
[server.rate_limits.storage]
type = "memory"  # or "redis" for distributed rate limiting

# Global rate limit (applies to all requests)
[server.rate_limits.global]
limit = 1000
interval = "60s"

# Per-IP rate limit
[server.rate_limits.per_ip]
limit = 100
interval = "60s"

# Per-MCP server rate limits
[mcp.servers.my_server.rate_limits]
limit = 50
interval = "60s"

LLM Provider Configuration

Nexus provides a unified interface for multiple LLM providers:

# OpenAI (or compatible)
[llm.providers.openai]
type = "openai"
api_key = "{{ env.OPENAI_API_KEY }}"

[llm.providers.openai.models.gpt-4]
[llm.providers.openai.models.gpt-3-5-turbo]

# Anthropic
[llm.providers.anthropic]
type = "anthropic"
api_key = "{{ env.ANTHROPIC_API_KEY }}"

[llm.providers.anthropic.models.claude-3-5-sonnet-20241022]

# Google
[llm.providers.google]
type = "google"
api_key = "{{ env.GOOGLE_API_KEY }}"

[llm.providers.google.models."gemini-1.5-flash"]

# AWS Bedrock
[llm.providers.bedrock]
type = "bedrock"
region = "us-west-2"

[llm.providers.bedrock.models."anthropic.claude-3-5-sonnet-20241022-v2:0"]

Using the LLM API

Once configured, you can interact with LLM providers through Nexus's unified API:

# List available models
curl http://localhost:8000/llm/models

# Chat completion
curl -X POST http://localhost:8000/llm/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello, how are you?"}
    ],
    "temperature": 0.7,
    "max_tokens": 150
  }'

# Streaming response
curl -X POST http://localhost:8000/llm/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-3-5-sonnet-20241022",
    "messages": [
      {"role": "user", "content": "Write a short poem"}
    ],
    "stream": true,
    "max_tokens": 100
  }'

Tool Calling Support

Nexus supports advanced tool calling across all LLM providers:

curl -X POST http://localhost:8000/llm/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-3-5-sonnet-20241022",
    "messages": [
      {"role": "user", "content": "What'\''s the weather in San Francisco?"}
    ],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get current weather for a location",
        "parameters": {
          "type": "object",
          "properties": {
            "location": {"type": "string", "description": "City and state"},
            "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
          },
          "required": ["location"]
        }
      }
    }],
    "tool_choice": "auto"
  }'

Adding to AI Assistants

Cursor

Add to your Cursor settings:

  1. Open Cursor Settings (Cmd+, on macOS)
  2. Search for "Model Context Protocol"
  3. Enable MCP support
  4. Add to the MCP server configuration:
{
  "nexus": {
    "transport": {
      "type": "http",
      "url": "http://localhost:8000/mcp"
    }
  }
}

Claude Code

Add to your Claude Code configuration:

claude mcp add --transport http nexus http://localhost:8000/mcp

Or add it to your project's .mcp.json file:

{
  "mcpServers": {
    "nexus": {
      "type": "http",
      "url": "http://localhost:8000/mcp"
    }
  }
}

Troubleshooting STDIO Servers

Server doesn't start

  • Check executable path: Ensure the command exists and is executable
  • View stderr output: Set stderr = "inherit" to see error messages
  • Verify JSON-RPC output: The server must output valid JSON-RPC on stdout
  • Check working directory: Ensure cwd path exists if specified

Tools not appearing

  • Wait for initialization: STDIO servers may take a moment to start
  • Use search: STDIO tools only appear in search results, not in the base tool list
  • Check server logs: Enable stderr logging to see if the server is responding to tool list requests

Security Considerations

  • Always use environment variables for sensitive tokens
  • Enable TLS verification for production deployments
  • Use CORS configuration to restrict access
  • Configure OAuth2 authentication for production deployments
  • Ensure JWKs URLs use HTTPS in production
  • Validate JWT token issuer and audience claims
  • Keep your MCP servers and Nexus updated
  • Be cautious when running STDIO servers with elevated privileges

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "nexus" '{"transport":{"type":"http","url":"http://localhost:8000/mcp"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "nexus": {
            "transport": {
                "type": "http",
                "url": "http://localhost:8000/mcp"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "nexus": {
            "transport": {
                "type": "http",
                "url": "http://localhost:8000/mcp"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later