Sponsored by Deepsite.site

MCP Neo4j Remote Server

Created By
artur-nohup7 months ago
Remote MCP Neo4j Memory Server with OAuth 2.1 and API Key Authentication - TypeScript implementation using FastMCP
Content

MCP Neo4j Remote Server

A remote Model Context Protocol (MCP) server that provides persistent memory capabilities through Neo4j graph database integration with OAuth 2.1 and API Key authentication.

Features

  • Remote Access: HTTP-based MCP server that can be accessed over the network
  • Dual Authentication:
    • OAuth 2.1 via Descope (for users/applications that support OAuth)
    • API Key authentication (for clients that only support API keys)
  • Neo4j Integration: Persistent graph-based memory storage
  • Docker Support: Containerized deployment with Docker Compose
  • Health Monitoring: Built-in health checks and monitoring endpoints
  • TypeScript: Full TypeScript implementation with type safety

Architecture

The server converts the original Python Neo4j MCP implementation to TypeScript using the FastMCP framework, enabling remote access with robust authentication.

Authentication Methods

  1. OAuth 2.1 (via Descope):

    • Use Authorization: Bearer <token> header
    • Supports multiple OAuth providers (Google, GitHub, Microsoft, etc.)
    • Full user session management
  2. API Key:

    • Use Authorization: ApiKey <key> header
    • Or x-api-key: <key> header
    • Or ?api_key=<key> query parameter

Quick Start

1. Installation

cd /workspace/mcp-neo4j-remote
npm install

2. Configuration

Copy .env.example to .env and configure:

cp .env.example .env

Edit .env with your settings:

# Neo4j Configuration
NEO4J_URI=bolt://macmini.arturs-server.com:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=nohuprsz

# API Keys (comma-separated)
API_KEYS=your-api-key-1,your-api-key-2

# Optional: Descope OAuth
DESCOPE_PROJECT_ID=your_project_id
DESCOPE_MANAGEMENT_KEY=your_management_key

3. Development

# Development with hot reload
npm run dev

# Build for production
npm run build

# Start production server
npm start

4. Docker Deployment

# Build and start with Docker Compose
docker-compose up --build

# Or build manually
docker build -t mcp-neo4j-remote .
docker run -p 8080:8080 --env-file .env mcp-neo4j-remote

Usage

Health Check

curl http://localhost:8080/health

MCP Connection

The server exposes an MCP endpoint at:

  • HTTP Stream: http://localhost:8080/stream

Authentication Examples

Using API Key:

curl -H "x-api-key: demo-key-12345" \
     -H "Content-Type: application/json" \
     http://localhost:8080/stream

Using OAuth Bearer Token:

curl -H "Authorization: Bearer <your-oauth-token>" \
     -H "Content-Type: application/json" \
     http://localhost:8080/stream

Available Tools

The server provides the same tools as the original Python implementation:

Query Tools

  • read_graph - Read the entire knowledge graph
  • search_nodes - Search for nodes based on a query
  • find_nodes / open_nodes - Find specific nodes by name

Entity Management

  • create_entities - Create multiple new entities
  • delete_entities - Delete entities and their relations

Relation Management

  • create_relations - Create relations between entities
  • delete_relations - Delete specific relations

Observation Management

  • add_observations - Add observations to existing entities
  • delete_observations - Delete specific observations

API Resources

Server Status

  • URI: mcp-neo4j://status
  • Provides server health, Neo4j stats, and authentication status

Authentication Info

  • URI: mcp-neo4j://auth-info
  • Provides available authentication methods and configuration

Testing Connection

Test the connection to your Neo4j server:

# Using the configured .env file
npm run dev

# Or test with curl (after server is running)
curl -H "x-api-key: demo-key-12345" \
     http://localhost:8080/health

Environment Variables

VariableDescriptionRequiredDefault
PORTServer portNo8080
NODE_ENVEnvironment modeNodevelopment
NEO4J_URINeo4j connection URIYes-
NEO4J_USERNAMENeo4j usernameYes-
NEO4J_PASSWORDNeo4j passwordYes-
NEO4J_DATABASENeo4j database nameNoneo4j
DESCOPE_PROJECT_IDDescope project IDNo-
DESCOPE_MANAGEMENT_KEYDescope management keyNo-
API_KEYSComma-separated API keysNo-
CORS_ORIGINSAllowed CORS originsNo*

Development

Project Structure

src/
├── auth/           # Authentication providers
│   ├── base.ts     # Abstract auth provider
│   ├── oauth.ts    # Descope OAuth provider
│   ├── apikey.ts   # API key provider
│   └── manager.ts  # Auth manager
├── neo4j/          # Neo4j integration
│   └── memory.ts   # Memory implementation
├── types/          # TypeScript type definitions
│   └── index.ts    # Shared types
├── server.ts       # FastMCP server setup
└── index.ts        # Main entry point

Scripts

  • npm run dev - Development with hot reload
  • npm run build - Build TypeScript to JavaScript
  • npm start - Start production server
  • npm test - Run tests
  • npm run lint - Lint code
  • npm run format - Format code

Security Considerations

  1. Environment Variables: Never commit .env files with real credentials
  2. API Keys: Use strong, unique API keys and rotate them regularly
  3. CORS: Configure CORS_ORIGINS appropriately for production
  4. HTTPS: Use HTTPS in production environments
  5. Network: Restrict network access to the server as needed

Troubleshooting

Connection Issues

  1. Neo4j Connection: Verify Neo4j is accessible and credentials are correct
  2. Port Conflicts: Ensure port 8080 is available or change in configuration
  3. Authentication: Check API keys or OAuth configuration

Common Errors

  • "Failed to connect to Neo4j": Check Neo4j URI, username, and password
  • "Authentication failed": Verify API keys or OAuth tokens
  • "Port already in use": Change the PORT environment variable

License

MIT License - see LICENSE file for details.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
WindsurfThe new purpose-built IDE to harness magic
ChatWiseThe second fastest AI chatbot™
Tavily Mcp
Amap Maps高德地图官方 MCP Server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
CursorThe AI Code Editor
DeepChatYour AI Partner on Desktop
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Playwright McpPlaywright MCP server
Serper MCP ServerA Serper MCP Server
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs