Get the FREE Ultimate OpenClaw Setup Guide →

mcp-inspector-integration

Scanned
npx machina-cli add skill a5c-ai/babysitter/mcp-inspector-integration --openclaw
Files (1)
SKILL.md
4.0 KB

MCP Inspector Integration

Set up MCP Inspector for debugging and testing MCP servers.

Capabilities

  • Configure MCP Inspector connection
  • Set up request/response logging
  • Implement protocol debugging
  • Create test scenarios
  • Generate inspection reports
  • Configure development workflows

Usage

Invoke this skill when you need to:

  • Debug MCP server communication
  • Test tool and resource handlers
  • Inspect protocol messages
  • Validate MCP implementation

Inputs

ParameterTypeRequiredDescription
serverPathstringYesPath to MCP server entry
transportstringNoTransport type (stdio, sse)
loggingbooleanNoEnable verbose logging

Generated Patterns

Inspector Configuration

{
  "mcpServers": {
    "my-server": {
      "command": "node",
      "args": ["dist/index.js"],
      "env": {
        "DEBUG": "mcp:*",
        "NODE_ENV": "development"
      }
    }
  }
}

Debug Wrapper Script

#!/usr/bin/env node
import { createServer } from './server';

// Enable debug logging
process.env.DEBUG = 'mcp:*';

// Log all stdin/stdout for debugging
const originalWrite = process.stdout.write.bind(process.stdout);
process.stdout.write = (chunk: any, ...args: any[]) => {
  if (process.env.MCP_DEBUG_LOG) {
    const fs = require('fs');
    fs.appendFileSync(
      process.env.MCP_DEBUG_LOG,
      `[OUT] ${new Date().toISOString()} ${chunk}\n`
    );
  }
  return originalWrite(chunk, ...args);
};

process.stdin.on('data', (chunk) => {
  if (process.env.MCP_DEBUG_LOG) {
    const fs = require('fs');
    fs.appendFileSync(
      process.env.MCP_DEBUG_LOG,
      `[IN] ${new Date().toISOString()} ${chunk}\n`
    );
  }
});

// Start server
createServer();

NPM Scripts for Development

{
  "scripts": {
    "dev": "tsx watch src/index.ts",
    "debug": "MCP_DEBUG_LOG=./debug.log tsx src/index.ts",
    "inspect": "npx @anthropic/mcp-inspector node dist/index.js",
    "test:mcp": "npx @anthropic/mcp-inspector --test node dist/index.js"
  }
}

Test Scenarios

// tests/mcp-scenarios.ts
export const testScenarios = [
  {
    name: 'List Tools',
    request: {
      jsonrpc: '2.0',
      method: 'tools/list',
      id: 1,
    },
    validate: (response: any) => {
      return response.result?.tools?.length > 0;
    },
  },
  {
    name: 'Call Tool - search_files',
    request: {
      jsonrpc: '2.0',
      method: 'tools/call',
      params: {
        name: 'search_files',
        arguments: { pattern: '*.ts', path: './src' },
      },
      id: 2,
    },
    validate: (response: any) => {
      return !response.error && response.result?.content;
    },
  },
  {
    name: 'List Resources',
    request: {
      jsonrpc: '2.0',
      method: 'resources/list',
      id: 3,
    },
    validate: (response: any) => {
      return Array.isArray(response.result?.resources);
    },
  },
];

// Run test scenarios
export async function runScenarios(
  send: (msg: any) => Promise<any>
): Promise<void> {
  for (const scenario of testScenarios) {
    console.log(`Testing: ${scenario.name}`);
    const response = await send(scenario.request);
    const passed = scenario.validate(response);
    console.log(`  ${passed ? '✓ PASS' : '✗ FAIL'}`);
    if (!passed) {
      console.log('  Response:', JSON.stringify(response, null, 2));
    }
  }
}

Workflow

  1. Install Inspector - Set up MCP Inspector
  2. Configure connection - Server path and args
  3. Enable logging - Debug output
  4. Create scenarios - Test cases
  5. Run inspection - Debug session
  6. Generate report - Inspection results

Target Processes

  • mcp-server-monitoring-debugging
  • mcp-server-testing-suite
  • mcp-tool-implementation

Source

git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/cli-mcp-development/skills/mcp-inspector-integration/SKILL.mdView on GitHub

Overview

MCP Inspector Integration sets up the MCP Inspector for debugging and testing MCP servers. It covers configuring connections, enabling request/response logging, and validating protocol flows with test scenarios and inspection reports. This helps ensure MCP implementations behave as expected across tool interactions and resources.

How This Skill Works

Configure the MCP Inspector connection using the inspector configuration (serverPath, command, args, env). Optionally enable verbose logging and choose a transport (stdio or SSE). Run predefined test scenarios or custom requests to capture logs, inspect responses, and validate protocol messages, then review generated reports.

When to Use It

  • Debug MCP server communication
  • Test tool and resource handlers
  • Inspect protocol messages between MCP clients and servers
  • Validate MCP implementation against expectations
  • Create repeatable test scenarios and reports for development workflows

Quick Start

  1. Step 1: Create an Inspector Configuration for your MCP server (e.g., mcpServers.my-server with command 'node', args ['dist/index.js'], and env with DEBUG='mcp::*').
  2. Step 2: Start debugging by enabling MCP_DEBUG_LOG (via the Debug Wrapper Script) and running the debug or dev npm script.
  3. Step 3: Run test scenarios (npm run test:mcp or npm run inspect) and review the resulting inspection report.

Best Practices

  • Centralize serverPath, command, and args in a single Inspector Configuration for maintainability.
  • Enable verbose logging only during debugging and rotate logs to avoid large files.
  • Construct realistic test scenarios (tools/list, tools/call, resources/list) to exercise protocol flows.
  • Use the provided NPM scripts (dev, debug, inspect, test:mcp) to standardize runs.
  • Review inspection reports regularly to verify protocol compliance and catch regressions.

Example Use Cases

  • Configure a server named 'my-server' with node dist/index.js and DEBUG=mcp:* in development.
  • Wrap IO with the Debug Wrapper Script to log all stdin/stdout to MCP_DEBUG_LOG.
  • Run npm scripts dev or debug to start the inspector and verify connections.
  • Execute test scenarios for tools/list and resources/list to validate MCP responses.
  • Open the generated inspection report to confirm protocol adherence and tool behavior.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers