Skip to content

MCP Server for Protocol Specifications and AI Test Generation #2

@amiable-dev

Description

@amiable-dev

MCP Server for Protocol Specifications

Overview

Create an MCP (Model Context Protocol) server that exposes Conductor's protocol specifications and enables AI-powered test generation. This infrastructure enables hardware-free testing and AI-assisted development.

Motivation

  • Enable AI/LLMs to understand Conductor's protocols (MIDI, Gamepad, OSC)
  • Generate realistic test data without physical hardware
  • Provide protocol specs as structured resources
  • Foundation for AI-assisted debugging and test creation

Architecture

New Crate: conductor-mcp-server

conductor-mcp-server/
├── Cargo.toml
├── src/
│   ├── main.rs              // MCP server binary
│   ├── server.rs            // MCP protocol implementation
│   ├── resources.rs         // Protocol spec resources
│   ├── tools.rs             // Test generation tools
│   └── schema/
│       ├── midi_spec.json       // MIDI protocol spec
│       ├── gamepad_spec.json    // Gamepad protocol spec (v3.0)
│       ├── input_event.json     // InputEvent enum structure
│       └── action_spec.json     // Action types spec

MCP Resources

Resources exposed via conductor:// URI scheme:

Protocol Specifications

conductor://protocols/midi

{
  "name": "MIDI Protocol",
  "events": {
    "NoteOn": { "note": "0-127", "velocity": "0-127" },
    "NoteOff": { "note": "0-127", "velocity": "0-127" },
    "CC": { "controller": "0-127", "value": "0-127" },
    "PitchBend": { "value": "0-16383" }
  },
  "id_range": "0-127"
}

conductor://protocols/gamepad

{
  "name": "Gamepad Protocol (v3.0)",
  "buttons": {
    "range": "128-144",
    "mapping": {
      "128": "South (A/Cross/B)",
      "129": "East (B/Circle/A)",
      ...
    }
  },
  "axes": {
    "range": "128-133",
    "analog_sticks": ["128-131"],
    "triggers": ["132-133"]
  },
  "id_range": "128-255"
}

conductor://protocols/input-events

  • Complete InputEvent enum definition
  • Event processing pipeline documentation
  • Trigger type mappings

conductor://recordings/{name}

  • Captured device recordings (JSON format)
  • Stored in .conductor/recordings/
  • Used for replay and AI training

MCP Tools

Tools available to AI/LLMs for test generation:

generate_test_sequence

Generate realistic input sequences based on natural language prompts.

Input:

{
  "prompt": "Generate a sequence simulating FPS gameplay with WASD movement",
  "protocol": "gamepad",
  "duration_ms": 5000,
  "output_format": "json"
}

Output:

{
  "sequence": [
    { "timestamp": 0, "event": "ButtonPressed", "button": 131, "comment": "W key (forward)" },
    { "timestamp": 100, "event": "AxisChanged", "axis": 130, "value": 255, "comment": "Right stick X (look right)" },
    ...
  ]
}

validate_message

Validate protocol message correctness.

Input:

{
  "protocol": "gamepad",
  "event": { "type": "ButtonPressed", "button": 128 }
}

Output:

{
  "valid": true,
  "warnings": [],
  "suggestions": ["Button 128 is South button (A/Cross/B)"]
}

suggest_test_cases

AI suggests edge cases and test scenarios.

Input:

{
  "feature": "VelocityRange trigger",
  "protocol": "midi"
}

Output:

{
  "test_cases": [
    "Boundary: velocity 40 (soft/medium boundary)",
    "Boundary: velocity 80 (medium/hard boundary)",
    "Edge: velocity 0 (note off)",
    "Edge: velocity 127 (maximum)",
    "Timing: rapid velocity changes"
  ]
}

Implementation Plan

Phase 1: MCP Server Core (2 hours)

  • Create conductor-mcp-server crate
  • Implement basic MCP protocol handling
  • Add JSON schema definitions for protocols
  • Implement resource serving

Phase 2: Protocol Specifications (1 hour)

  • Extract MIDI spec from conductor-core
  • Extract Gamepad spec (v3.0 mappings)
  • Document InputEvent structure
  • Create JSON schemas

Phase 3: AI Tools Implementation (2 hours)

  • Implement generate_test_sequence tool
  • Implement validate_message tool
  • Implement suggest_test_cases tool
  • Add LLM prompt templates

Phase 4: Testing & Documentation (1 hour)

  • Test with Claude Desktop MCP integration
  • Test with other MCP clients
  • Write usage documentation
  • Add examples

Usage Examples

Running the MCP Server

# Start MCP server
conductor-mcp-server --port 3000

# Or via stdio for Claude Desktop integration
conductor-mcp-server --stdio

Claude Desktop Configuration

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "conductor": {
      "command": "conductor-mcp-server",
      "args": ["--stdio"]
    }
  }
}

AI-Powered Test Generation

User: Generate a test sequence for a fighting game combo
AI: [Uses generate_test_sequence tool]
    - Button 128 (A) press at 0ms
    - Button 129 (B) press at 100ms  
    - Button chord [130, 131] at 200ms
    - Creates realistic frame-perfect timing

Benefits

  1. Hardware-Free Testing: Generate test data without physical devices
  2. AI-Assisted Development: Natural language → test sequences
  3. Protocol Documentation: Machine-readable specs
  4. Test Coverage: AI suggests edge cases
  5. Future Protocols: Easy to add OSC, keyboard, etc.

Dependencies

[dependencies]
serde = { workspace = true }
serde_json = { workspace = true }
tokio = { workspace = true }
conductor-core = { path = "../conductor-core" }
# MCP SDK (to be determined)

Timeline

Total: 6-8 hours

  • Phase 1: 2 hours (core server)
  • Phase 2: 1 hour (protocol specs)
  • Phase 3: 2 hours (AI tools)
  • Phase 4: 1 hour (testing/docs)

Blockers

None - this is foundational work that doesn't depend on other issues.

Blocked Issues

Labels

enhancement, testing, ai, infrastructure, v3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions