macharpe/meraki-mcp-cloudflare
If you are the rightful owner of meraki-mcp-cloudflare 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 Cisco Meraki MCP Server is a Model Context Protocol server that integrates AI assistants with Cisco Meraki network management capabilities, running on Cloudflare Workers.
๐ Cisco Meraki MCP Server
A Model Context Protocol (MCP) server that provides AI assistants with direct access to Cisco Meraki network management capabilities. Built on Cloudflare Workers with Durable Objects and OAuth 2.0 authentication via Cloudflare Access.
Prerequisites: Requires a Cloudflare account and domain for custom domain setup and OAuth authentication.
Inspiration: This implementation was inspired by Censini/mcp-server-meraki - credits to the original work for additional API method ideas.
โจ Features
๐ ๏ธ Available Tools
The server provides 18 comprehensive Meraki management tools:
๐ข Organization & Network Management
get_organizations
- List all organizations in your Meraki accountget_organization
- Get detailed information about a specific organizationget_networks
- List all networks within an organizationget_network
- Get detailed information about a specific network
๐ฑ Device Management
get_devices
- List all devices within a networkget_device
- Get detailed information about a specific deviceget_device_statuses
- Get device statuses for an organizationget_management_interface
- Get management interface settings for a device
๐ Network Operations
get_clients
- Get clients connected to a networkget_network_traffic
- Get network traffic statisticsget_network_events
- Get recent network events
๐ Switch Management
get_switch_ports
- Get switch ports for a deviceget_switch_port_statuses
- Get switch port statuses for a deviceget_switch_routing_interfaces
- Get routing interfaces for a switchget_switch_static_routes
- Get static routes for a switch
๐ก Wireless Management
get_wireless_radio_settings
- Get wireless radio settings for an access pointget_wireless_status
- Get wireless status of an access pointget_wireless_latency_stats
- Get wireless latency statistics for an access point
๐ฏ Key Benefits
- ๐ Serverless: Runs on Cloudflare Workers with automatic scaling
- ๐ OAuth 2.0 Security: Secure authentication via Cloudflare Access
- ๐ Custom Domain: Professional branded domain with SSL
- ๐ฑ Real-time: Live access to your Meraki dashboard data
- ๐ฐ Cost-effective: Pay-per-use with Cloudflare Workers free tier
- โก Durable Objects: Persistent MCP agent instances
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ MCP Client โ โ Durable Object โ โ Meraki API โ
โ (Claude) โโโโโบโ MCP Agent โโโโโบโ Dashboard โ
โ โ โ + OAuth Handler โ โ โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
OAuth 2.0 Flow Cloudflare Workers HTTPS/REST API
โฒ โฒ
โโโโโโโโโโโโโโโโโโโโโโโโ
Cloudflare Access
(Identity Provider)
๐ OAuth Authentication Flow
The server implements OAuth 2.0 with Cloudflare Access, providing secure authentication for MCP clients.
sequenceDiagram
participant Client as MCP Client
participant Worker as Cloudflare Worker
participant Access as Cloudflare Access
participant Meraki as Meraki API
Client->>Worker: 1. Initialize OAuth flow
Worker->>Access: 2. Redirect to authorization
Access->>Access: 3. User authenticates (SSO)
Access->>Worker: 4. Return authorization code
Worker->>Access: 5. Exchange code for token
Access->>Worker: 6. Return JWT access token
Worker->>Worker: 7. Validate JWT & extract claims
Client->>Worker: 8. MCP request with token
Worker->>Meraki: 9. API call with Meraki key
Meraki->>Worker: 10. Return data
Worker->>Client: 11. Return MCP response
OAuth Features
- OAuth 2.0 + PKCE: Secure authorization code flow with PKCE
- JWT Tokens: Cryptographically signed tokens from Cloudflare Access
- User Approval: Optional client approval dialog for consent management
- Session Storage: KV-based storage for OAuth state and tokens
- SSO Integration: Supports Google, Azure AD, and other identity providers
๐ Project Structure
meraki-mcp-cloudflare/
โโโ src/
โ โโโ index.ts # Main Durable Object MCP Agent
โ โโโ access-handler.ts # OAuth authentication handler
โ โโโ workers-oauth-utils.ts# OAuth utility functions
โ โโโ services/
โ โ โโโ merakiapi.ts # Meraki API service layer
โ โโโ types/
โ โ โโโ env.ts # Environment type definitions
โ โ โโโ meraki.ts # Meraki API type definitions
โ โโโ errors.ts # Custom error classes
โโโ wrangler.jsonc # Cloudflare Workers configuration
โโโ package.json # Dependencies and scripts
โโโ CLAUDE.md # Claude Code instructions
โโโ README.md # This file
๐ Prerequisites
Before deploying the server, ensure you have:
- ๐ Cloudflare Account: Free account at cloudflare.com
- ๐ Domain in Cloudflare: Your domain must be managed by Cloudflare for OAuth authentication
- ๐ Cisco Meraki Account: With API access enabled
- ๐ซ Meraki API Key: Generated from your Meraki Dashboard
- ๐ป Node.js: Version 18 or higher
- ๐ฆ Git: For cloning the repository
๐ Getting Your Meraki API Key
- Log into your Meraki Dashboard
- Navigate to Organization > Settings > Dashboard API access
- Enable API access if not already enabled
- Generate a new API key and copy it securely
๐ Cloudflare Access OAuth Setup
Before deploying the server, you need to configure Cloudflare Access as the OAuth identity provider. This section walks you through creating the SaaS application that provides the OAuth secrets.
1. Create Cloudflare Access Application
-
Navigate to Cloudflare Zero Trust:
- Go to Cloudflare Dashboard
- Select your account โ Zero Trust โ Access โ Applications
-
Create SaaS Application:
- Click "Add an application"
- Select "SaaS" application type
- Choose "Custom" as the SaaS provider
-
Configure Application Details:
Application name: Meraki MCP Server Entity ID: meraki-mcp-server Name ID format: Email
-
Set Application Domain:
- Enter your custom domain:
meraki-mcp.yourdomain.com
- This should match the domain in your
wrangler.jsonc
routes
- Enter your custom domain:
2. Configure OAuth Settings
-
OAuth 2.0 Settings:
- Grant Type: Authorization Code
- Redirect URI:
https://meraki-mcp.yourdomain.com/callback
- Scopes:
openid email profile
-
Security Settings:
- Enable PKCE (Proof Key for Code Exchange)
- Set Token Lifetime: 1 hour (3600 seconds)
- Enable Refresh Tokens: Yes
3. Extract OAuth Configuration Values
After creating the application, Cloudflare will provide these values needed for your Worker secrets:
# From the SaaS application configuration page:
ACCESS_CLIENT_ID="your_oauth_client_id_here"
ACCESS_CLIENT_SECRET="your_oauth_client_secret_here"
# From your Cloudflare Zero Trust team settings:
ACCESS_TOKEN_URL="https://your-team.cloudflareaccess.com/cdn-cgi/access/token"
ACCESS_AUTHORIZATION_URL="https://your-team.cloudflareaccess.com/cdn-cgi/access/authorize"
ACCESS_JWKS_URL="https://your-team.cloudflareaccess.com/cdn-cgi/access/certs"
Note: Replace your-team
with your actual Cloudflare Zero Trust team name (found in your team dashboard URL).
4. Configure Access Policies
Create access policies to control who can authenticate:
-
Navigate to Policies:
- Go to Zero Trust โ Access โ Policies
-
Create Application Policy:
- Application: Select your "Meraki MCP Server" app
- Action: Allow
- Session Duration: 1 day
-
Set Include Rules (choose one):
# Option 1: Specific email addresses Rule type: Include Selector: Email Value: your-email@domain.com # Option 2: Email domain Rule type: Include Selector: Email domain Value: yourdomain.com # Option 3: Everyone (not recommended) Rule type: Include Selector: Everyone
5. Generate Cookie Encryption Key
The COOKIE_ENCRYPTION_KEY
is used to encrypt session data and approval cookies for security.
# Generate a secure 32-byte base64 key
openssl rand -base64 32
Purpose: This key encrypts:
- Session cookies: Contains OAuth state and user approval decisions
- PKCE code verifier: Stored temporarily during OAuth flow
- User approval state: Remembers which clients the user has approved
Security Note:
- Keep this key secret and secure
- If compromised, regenerate it (will invalidate all active sessions)
- Use a different key for each deployment environment
6. Test OAuth Configuration
Before deploying, verify your OAuth setup:
-
Test Authorization URL:
curl -I "https://your-team.cloudflareaccess.com/cdn-cgi/access/authorize?client_id=YOUR_CLIENT_ID&response_type=code"
-
Verify JWKS Endpoint:
curl "https://your-team.cloudflareaccess.com/cdn-cgi/access/certs"
-
Check Team Configuration:
- Ensure your team domain is active
- Verify your identity provider (Google, Azure, etc.) is configured
- Test SSO login through the Access dashboard
๐ Installation & Deployment
1. Clone the Repository
git clone https://github.com/macharpe/meraki-mcp-cloudflare.git
cd meraki-mcp-cloudflare
2. Install Dependencies
npm install
3. Configure Environment
Create a .dev.vars
file for local development:
echo "MERAKI_API_KEY=your_meraki_api_key_here" > .dev.vars
4. Configure Custom Domain
Update wrangler.jsonc
with your domain:
{
"name": "meraki-mcp-cloudflare",
"main": "src/index.ts",
"compatibility_date": "2025-08-04",
"compatibility_flags": ["nodejs_compat"],
"vars": {
"MERAKI_BASE_URL": "https://api.meraki.com/api/v1"
},
"durable_objects": {
"bindings": [
{
"class_name": "MerakiMCPAgent",
"name": "MCP_OBJECT"
}
]
},
"kv_namespaces": [
{
"binding": "OAUTH_KV",
"id": "your-kv-namespace-id"
}
],
"routes": [
{
"pattern": "meraki-mcp.yourdomain.com",
"custom_domain": true
}
],
"workers_dev": false,
"preview_urls": false
}
5. Create KV Namespace
Create a KV namespace for OAuth session storage:
npx wrangler kv:namespace create "OAUTH_KV"
Update the namespace ID in wrangler.jsonc
with the returned ID.
6. Set Required Secrets
Set your API key and OAuth configuration as secrets:
# Required - Meraki API key
npx wrangler secret put MERAKI_API_KEY
# Required - OAuth configuration secrets
npx wrangler secret put ACCESS_CLIENT_ID
npx wrangler secret put ACCESS_CLIENT_SECRET
npx wrangler secret put ACCESS_TOKEN_URL
npx wrangler secret put ACCESS_AUTHORIZATION_URL
npx wrangler secret put ACCESS_JWKS_URL
npx wrangler secret put COOKIE_ENCRYPTION_KEY
7. Deploy to Cloudflare Workers
First, authenticate with Cloudflare:
npx wrangler login
Deploy the server:
npx wrangler deploy
Your server will be available at: https://meraki-mcp.yourdomain.com
โ๏ธ Claude Desktop Configuration
๐ป Setup Instructions
-
Locate your Claude Desktop config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
Add the Meraki MCP server configuration:
{
"mcpServers": {
"meraki": {
"command": "npx",
"args": [
"-y",
"mcp-remote@latest",
"https://meraki-mcp.yourdomain.com"
]
}
}
}
-
Replace with your actual values:
yourdomain.com
โ Your actual domain configured in Cloudflare
-
Restart Claude Desktop completely (quit and relaunch)
โ Verify Configuration
Check that the server is properly connected:
- Open Claude Desktop
- Start a new conversation
- Try: "List my Meraki organizations"
The first time you use the server, you'll be prompted to complete OAuth authentication in your browser.
๐ Environment Variables
The server uses these environment variables:
Required
MERAKI_API_KEY
- Your Cisco Meraki API key (stored as Worker secret)ACCESS_CLIENT_ID
- OAuth client ID from Cloudflare AccessACCESS_CLIENT_SECRET
- OAuth client secret from Cloudflare AccessACCESS_TOKEN_URL
- OAuth token endpoint URLACCESS_AUTHORIZATION_URL
- OAuth authorization endpoint URLACCESS_JWKS_URL
- JWKS endpoint for token verificationCOOKIE_ENCRYPTION_KEY
- Key for encrypting session cookies
Optional
MERAKI_BASE_URL
- Base URL for Meraki API (defaults tohttps://api.meraki.com/api/v1
)
Setting Secrets
# Required
npx wrangler secret put MERAKI_API_KEY
npx wrangler secret put ACCESS_CLIENT_ID
npx wrangler secret put ACCESS_CLIENT_SECRET
npx wrangler secret put ACCESS_TOKEN_URL
npx wrangler secret put ACCESS_AUTHORIZATION_URL
npx wrangler secret put ACCESS_JWKS_URL
npx wrangler secret put COOKIE_ENCRYPTION_KEY
๐ก Usage Examples
Once connected to Claude Desktop, you can use natural language to interact with your Meraki infrastructure:
๐ข Get Organizations
"Show me all my Meraki organizations"
๐ List Networks
"Get all networks in organization 123456"
๐ฑ View Devices
"List all devices in the main office network"
๐ Device Details
"Get details for device with serial ABC123DEF456"
๐ก Wireless Management
"Show me the wireless status of access point with serial XYZ789"
"Get wireless latency statistics for the office AP"
๐ Switch Operations
"List all switch ports for device ABC123"
"Show me the routing interfaces for the core switch"
๐ Network Analytics
"Get network traffic statistics for the main office"
"Show recent security events for organization 123456"
๐ API Endpoints
The server exposes these HTTP endpoints:
GET /
- OAuth provider and MCP agent handlerPOST /
- OAuth provider and MCP agent handlerGET /authorize
- OAuth authorization endpointPOST /authorize
- OAuth approval handlerGET /callback
- OAuth callback handlerGET /health
- Health check endpoint
Health Check Response
{
"status": "healthy",
"timestamp": "2025-08-29T12:00:00.000Z",
"service": "meraki-mcp-server",
"hasApiKey": true,
"oauthEnabled": true,
"version": "1.0.0",
"tools": 18,
"durableObjects": ["MerakiMCPAgent"],
"kvNamespaces": ["OAUTH_KV"]
}
๐ ๏ธ Development
๐ Available Scripts
npm run dev # Start local development server
npm run build # Build TypeScript to JavaScript
npm run deploy # Deploy to Cloudflare Workers
npm run lint # Run ESLint
npm run format # Format code with Prettier
๐งช Local Development
# Start local server
npm run dev
# Test health endpoint
curl http://localhost:8787/health
# Test with service tokens (if configured)
curl -H "CF-Access-Client-Id: your-client-id" \
-H "CF-Access-Client-Secret: your-client-secret" \
http://localhost:8787/health
โ Adding New Tools
To add new Meraki API endpoints:
- Add the method to
src/services/merakiapi.ts
- Define types in
src/types/meraki.ts
- Add the tool definition in
src/index.ts
- Add the tool handler in the switch statement
Example:
// Add to tools array
{
name: "get_clients",
description: "Get clients connected to a network",
inputSchema: {
type: "object",
properties: {
networkId: { type: "string", description: "Network ID" }
},
required: ["networkId"]
}
}
// Add to switch statement
case "get_clients":
const clients = await merakiService.getClients(args.networkId);
return { content: [{ type: "text", text: JSON.stringify(clients, null, 2) }] };
๐ Security Features
๐ก๏ธ Zero Trust Architecture
- Cloudflare Access: Enterprise-grade authentication at the edge
- Service Tokens: Machine-to-machine authentication without user interaction
- Custom Domain: Professional branded endpoint with automatic SSL
- Edge Validation: All authentication happens at Cloudflare's edge before reaching your Worker
๐ Data Protection
- API Keys: Stored as encrypted Cloudflare Worker secrets
- JWT Validation: Cloudflare Access provides signed JWT tokens
- HTTPS Only: All communication encrypted in transit
- No Data Storage: Server is stateless with no data persistence
๐จ Access Control
- AUD Token: Application-specific audience validation
- Team Domain: Organization-level access control
- Rate Limiting: Built-in DDoS protection via Cloudflare
- Geographic Controls: Optional geo-blocking capabilities
๐ Troubleshooting
โ ๏ธ Common Issues
"MERAKI_API_KEY not configured"
- Ensure you've set the secret:
npx wrangler secret put MERAKI_API_KEY
"403 Forbidden" from custom domain
- Check Cloudflare Access configuration
- Verify service tokens are correct
- Ensure domain is properly configured in Cloudflare
"Server disconnected" in Claude Desktop
- Check your Claude Desktop config file syntax
- Verify service tokens are correctly formatted
- Restart Claude Desktop after config changes
"Unauthorized - Valid service token required"
- Verify service tokens in Claude Desktop config
- Check that Cloudflare Access application is properly configured
- Ensure the custom domain is working
๐ Debugging
Check Cloudflare Workers logs:
npx wrangler tail
View Claude Desktop MCP logs:
# macOS
tail -f ~/Library/Logs/Claude/mcp-server-meraki.log
# Windows
Get-Content $env:APPDATA\Claude\logs\mcp-server-meraki.log -Wait
Test authentication manually:
curl -H "CF-Access-Client-Id: your-client-id" \
-H "CF-Access-Client-Secret: your-client-secret" \
https://meraki-mcp.yourdomain.com/health
๐ค Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-tool
- Make your changes and test locally
- Commit your changes:
git commit -am 'Add new tool'
- Push to the branch:
git push origin feature/new-tool
- Submit a pull request
๐ License
This project is licensed under the GNU General Public License v3.0 - see the file for details.
๐ Code Statistics
Project Metrics
๐ Total Files: ~25
๐ Source Files: 7 TypeScript files
๐ ๏ธ Available Tools: 18 Meraki API methods
๐ง API Service Methods: 20+ methods
๐ฆ Dependencies: 5 main packages (@modelcontextprotocol/sdk, agents, zod, @cloudflare/workers-oauth-provider, workers-mcp)
โก Architecture: Durable Objects + OAuth 2.0
File Breakdown
src/
โโโ index.ts # ~400 lines - Durable Object MCP Agent
โโโ access-handler.ts # ~150 lines - OAuth authentication handler
โโโ workers-oauth-utils.ts# ~200 lines - OAuth utility functions
โโโ services/
โ โโโ merakiapi.ts # ~190 lines - Meraki API service layer
โโโ types/
โ โโโ env.ts # ~15 lines - Environment type definitions
โ โโโ meraki.ts # ~308 lines - Meraki API type definitions
โโโ errors.ts # ~19 lines - Custom error classes
API Coverage
- Organizations: 2 methods (list, get details)
- Networks: 4 methods (list, details, traffic, events)
- Devices: 4 methods (list, details, status, management)
- Wireless: 3 methods (radio settings, status, latency stats)
- Switch: 4 methods (ports, port status, routing, static routes)
- Clients: 1 method (network clients)
Performance
- Cold Start: ~50ms on Cloudflare Workers (Durable Objects)
- Response Time: <100ms for most API calls
- Rate Limits: Respects Meraki API limits (5 requests/second)
- OAuth Flow: ~2-3 second authentication flow
๐ Related Resources
- Model Context Protocol (MCP)
- Cisco Meraki API Documentation
- Cloudflare Workers Documentation
- Cloudflare Access Documentation
- Claude Desktop MCP Setup
๐ฌ Support
For issues and questions:
- Create an issue in this repository
- Check the MCP documentation
- Review Cloudflare Workers error handling
- Consult OAuth Provider documentation
Last updated: August 2025