← Back to Home

Claude Code Integration Guide

Add MCPulse reliability monitoring to your Claude Code MCP servers in under 5 minutes.

Prerequisites

Step 1: Install the Monitor Package

Navigate to your MCP server directory and install mcpulse-monitor:

npm install mcpulse-monitor

Step 2: Wrap Your MCP Server

MCPulse uses a wrapper pattern to monitor your server without modifying your existing code. Here's how to integrate it:

Original MCP Server Code:

// server.js
import { McpServer } from '@modelcontextprotocol/sdk';

const server = new McpServer({
  name: 'my-mcp-server',
  version: '1.0.0'
});

server.tool('search', async (params) => {
  // Your search logic
  return { results: [...] };
});

server.tool('analyze', async (params) => {
  // Your analyze logic
  return { insights: [...] };
});

server.start();

With MCPulse Monitoring:

// server.js
import { McpServer } from '@modelcontextprotocol/sdk';
import { wrapMcpServer } from 'mcpulse-monitor';

const server = new McpServer({
  name: 'my-mcp-server',
  version: '1.0.0'
});

server.tool('search', async (params) => {
  // Your search logic
  return { results: [...] };
});

server.tool('analyze', async (params) => {
  // Your analyze logic
  return { insights: [...] };
});

// Wrap server before starting
const monitoredServer = wrapMcpServer(server, {
  serverId: 'your-server-id-from-dashboard', // Get this from MCPulse dashboard
  reportInterval: 60000, // Report every 60 seconds
  batchSize: 50 // Batch 50 events before sending
});

monitoredServer.start();

Step 3: Update Claude Code Config

Claude Code reads MCP servers from ~/.claude/config.json (or %APPDATA%\.claude\config.json on Windows).

Example Config:

{
  "mcpServers": {
    "my-mcp-server": {
      "command": "node",
      "args": ["/path/to/your/server.js"],
      "env": {
        "MCPULSE_SERVER_ID": "your-server-id-from-dashboard"
      }
    }
  }
}

💡 Pro Tip: You can pass the server ID via environment variable instead of hardcoding it in your code. Just read process.env.MCPULSE_SERVER_ID in your server wrapper.

Step 4: Verify Monitoring

Restart Claude Code and trigger a few MCP tool calls. Then check your MCPulse dashboard:

  1. Go to MCPulse Dashboard
  2. Find your server in the server list
  3. Click to view detailed metrics

Expected Output in Dashboard:

Reliability Score

98.7%

Avg Response Time

124ms

Uptime (24h)

99.9%

Error Rate

0.3%

Advanced: Server Selection Based on Reliability

Use the MCPulse API to programmatically select the most reliable MCP servers for your Claude Code workflows:

import axios from 'axios';

async function selectBestServer(serverIds) {
  const response = await axios.get('https://stacks.polsia.app/api/reliability', {
    headers: {
      'Authorization': `Bearer YOUR_API_KEY`
    },
    params: {
      server_ids: serverIds.join(',')
    }
  });

  // Sort by reliability score (descending)
  const sorted = response.data.servers.sort((a, b) =>
    b.reliability_score - a.reliability_score
  );

  return sorted[0]; // Return most reliable server
}

// Example usage:
const bestServer = await selectBestServer([
  'server-id-1',
  'server-id-2',
  'server-id-3'
]);

console.log(`Using server: ${bestServer.name} (${bestServer.reliability_score}% reliable)`);

Troubleshooting

❌ No data appearing in dashboard

  • Verify your server ID is correct (check dashboard for the exact ID)
  • Ensure your server is actually receiving requests in Claude Code
  • Check that wrapMcpServer() is called before server.start()
  • Look for network errors in your server logs (MCPulse reports via HTTPS)

⚠️ Server crashes after adding wrapper

  • Check Node.js version (requires 18+)
  • Verify mcpulse-monitor is installed in the correct directory
  • Run npm list mcpulse-monitor to confirm installation
  • Check for conflicting monitoring/instrumentation libraries

🔍 Metrics seem incorrect

  • Wait 2-3 minutes for initial aggregation to complete
  • MCPulse calculates rolling averages over 1h, 6h, 24h, and 7d windows
  • Very low request volumes may show volatile scores initially
  • Check that your server clock is synchronized (NTP)

Full API Reference

For complete API documentation including all endpoints, authentication, rate limits, and response schemas:

View Full API Docs →

Next Steps

Other Integration Guides