n8n-ai-agent-mcp-server

bytebool/n8n-ai-agent-mcp-server

3.2

If you are the rightful owner of n8n-ai-agent-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The N8N AI Agent MCP Server is a secure and scalable server designed for integrating N8N AI Agent with MongoDB and Context7 tools, leveraging Cloudflare Workers for global deployment.

Tools
  1. mongodb-find

    Query collections with filters and options.

  2. mongodb-aggregate

    Run aggregation pipelines.

  3. mongodb-list-databases

    List available databases.

  4. context7-search

    Search technical documentation.

  5. get-request-stats

    Get server request statistics.

N8N AI Agent MCP Server

A secure Cloudflare Workers MCP server for N8N AI Agent integration with MongoDB and Context7 tools.

Features

  • MongoDB Tools: Query databases, run aggregations, and list collections
  • Context7 Integration: Search technical documentation and knowledge bases
  • Secure Authentication: API key validation with MongoDB credential storage
  • Cloudflare Workers: Deployed on Cloudflare's global edge network
  • Durable Objects: Stateful session management
  • Rate Limiting: Built-in request throttling and security features

Quick Start

1. Prerequisites

  • Node.js 18+
  • Cloudflare account with Workers enabled
  • MongoDB Data API credentials
  • Context7 API key (optional)

2. Installation

git clone <repository-url>
cd MCPServerCode
npm install

3. Configuration

Set up your environment variables using Wrangler:

# Required MongoDB credentials
npx wrangler secret put MONGODB_DATA_API_KEY
npx wrangler secret put MONGODB_APP_ID

# Optional configurations
npx wrangler secret put MONGODB_DATA_SOURCE  # default: bytebool-server-cluster
npx wrangler secret put MONGODB_DATABASE     # default: claude_learning

# Optional Context7 integration
npx wrangler secret put CONTEXT7_API_KEY

# Optional authentication
npx wrangler secret put VALID_API_KEYS       # comma-separated API keys

4. Create KV Namespace

npx wrangler kv:namespace create "MCP_SECURITY"
# Update wrangler.toml with the returned namespace ID

5. Deploy

npx wrangler deploy

Available Tools

MongoDB Tools

  • mongodb-find - Query collections with filters and options
  • mongodb-aggregate - Run aggregation pipelines
  • mongodb-list-databases - List available databases

Context7 Tools

  • context7-search - Search technical documentation
  • context7-get-docs - Get comprehensive library documentation

Utility Tools

  • get-request-stats - Get server request statistics

N8N Integration

Configure your N8N MCP Client Tool node:

{
  "serverUrl": "https://your-worker.your-subdomain.workers.dev/sse",
  "apiKey": "your-api-key-here",
  "tools": [
    "mongodb-find",
    "mongodb-aggregate",
    "mongodb-list-databases",
    "context7-search",
    "get-request-stats"
  ]
}

Local Development

  1. Create a .dev.vars file:
MONGODB_DATA_API_KEY=your-mongodb-data-api-key
MONGODB_APP_ID=your-mongodb-app-id
CONTEXT7_API_KEY=your-context7-api-key
VALID_API_KEYS=dev-key-1,dev-key-2
  1. Start the development server:
npx wrangler dev
  1. Test with MCP Inspector:
npx @modelcontextprotocol/inspector@latest

Security Features

  • API Key Authentication: Validates requests against configured API keys
  • MongoDB Credential Storage: Encrypted credential validation
  • Rate Limiting: Configurable request throttling
  • IP Whitelisting: Optional IP address filtering
  • Request Logging: Security event tracking

Environment Variables

VariableRequiredDescription
MONGODB_DATA_API_KEYYesMongoDB Data API key
MONGODB_APP_IDYesMongoDB App ID for Data API
MONGODB_DATA_SOURCENoData source name (default: bytebool-server-cluster)
MONGODB_DATABASENoDatabase name (default: claude_learning)
CONTEXT7_API_KEYNoContext7 API key for documentation search
VALID_API_KEYSNoComma-separated list of valid API keys
IP_WHITELISTNoComma-separated list of allowed IPs
RATE_LIMIT_PER_MINUTENoMax requests per minute per IP

Architecture

  • Cloudflare Workers: Serverless edge computing platform
  • Durable Objects: Stateful session management with SQLite
  • KV Storage: Distributed key-value store for caching
  • MongoDB Data API: Database operations
  • Context7: Knowledge base integration

Testing

# Run all tests
npm test

# Test specific functionality
npm test -- --grep "authentication"

# Watch mode
npm test -- --watch

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

MIT