Crate bevy_debugger_mcp

Crate bevy_debugger_mcp 

Source
Expand description

§Bevy Debugger MCP

AI-assisted debugging for Bevy games through Claude Code using Model Context Protocol.

This crate provides a comprehensive debugging toolkit for Bevy games, enabling natural language interaction with game state through Claude Code. It bridges the gap between AI assistance and game development by offering intelligent observation, experimentation, and analysis capabilities.

§Quick Start

  1. Add BRP to your Bevy game:
[dependencies]
bevy = { version = "0.12", features = ["bevy_remote_protocol"] }
  1. Enable BRP in your game:
use bevy::prelude::*;
use bevy::remote::RemotePlugin;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(RemotePlugin::default())
        .run();
}
  1. Install and configure the MCP server:
cargo install bevy_debugger_mcp
bevy-debugger-mcp --help
  1. Configure Claude Code:
{
  "mcpServers": {
    "bevy-debugger-mcp": {
      "command": "bevy-debugger-mcp",
      "args": [],
      "type": "stdio"
    }
  }
}

§Features

  • 🔍 Natural Language Queries: Ask about your game state in plain English
  • 🧪 Controlled Experiments: Test hypotheses with systematic variations
  • 📊 Performance Analysis: Monitor and analyze game performance in real-time
  • ⏱️ Time-Travel Debugging: Record, replay, and branch timelines
  • 🚨 Anomaly Detection: Automatically detect unusual patterns in game behavior
  • 📈 Stress Testing: Systematically test your game under various loads
  • 🔧 Tool Orchestration: Chain debugging operations into complex workflows

§Core Modules

§Observation and Query

§Experimentation and Testing

§Time and State Management

§Analysis and Monitoring

§Infrastructure

  • mcp_server - Model Context Protocol server implementation
  • tool_orchestration - Complex debugging workflow coordination
  • error - Comprehensive error handling and recovery
  • config - Configuration management

§Example Usage

use bevy_debugger_mcp::prelude::*;

// Connect to your Bevy game
let mut client = BrpClient::connect("ws://localhost:15702").await?;

// Parse natural language queries
let parser = RegexQueryParser::new();
let request = parser.parse("find entities with Transform and Velocity")?;

// Execute the query
let response = client.send_request(request).await?;
println!("Found entities: {:?}", response);

§Architecture

The system follows a modular architecture:

Claude Code ←→ MCP Protocol ←→ MCP Server ←→ BRP Protocol ←→ Bevy Game
                                   ↓
                             Tool Modules
                          (observe, experiment,
                           stress, replay, etc.)

§Error Handling

All operations return Result<T, Error> types. The system includes comprehensive error recovery with automatic reconnection, dead letter queues for failed operations, and checkpoint/restore capabilities.

Modules§

anomaly_detector
brp_client
brp_command_handler
brp_integration
brp_messages
checkpoint
command_cache
compile_opts
config
dead_letter_queue
debug_brp_handler
debug_command_processor
diagnostics
entity_inspector
error
experiment_system
hot_reload
hypothesis_system
issue_detector
issue_detector_processor
lazy_init
mcp_server
memory_profiler
memory_profiler_processor
pattern_learning
performance_budget
performance_budget_processor
playback_system
prelude
Common imports for typical usage
profiling
query_builder
query_builder_processor
query_parser
recording_system
resource_manager
response_pool
semantic_analyzer
session_manager
session_processor
state_diff
stress_test_system
suggestion_engine
system_profiler
system_profiler_processor
timeline_branching
tool_orchestration
tools
visual_debug_overlay
visual_debug_overlay_processor
workflow_automation

Macros§

concat_strs
Compile-time string concatenation for efficiency
debug_only
Zero-cost abstraction for debug-only operations
fast_path
Fast path for common cases with minimal overhead
feature_enabled
Zero-overhead feature flag checks
feature_stub
No-op implementations for disabled features
if_optimized
Conditional compilation based on optimization level
likely_if
Branch prediction hints for hot paths
profile_async_block
Async version of profile_block macro
profile_block
Macro for easy profiling of code blocks
release_only
Zero-cost abstraction for release-only operations
static_assert_config
Compile-time assertions for configuration validation
unlikely_if
with_feature
Conditional compilation for different feature sets
without_feature