Bevy MCP Reference Implementation

A reference implementation demonstrating AI-assisted game development with Bevy game engine using the Bevy Remote Protocol (BRP) MCP server and Claude Code.

๐ŸŽฎ Overview

This project showcases how to integrate Claude Code with a Bevy game engine instance for interactive development, live debugging, and real-time entity manipulation. Using the Bevy Remote Protocol (BRP), you can query, inspect, and modify your running game without recompiling.

โœจ Features

  • Live Game Inspection: Query entities, components, and resources in real-time
  • Real-time Editing: Modify transforms, materials, and game state without recompiling
  • AI-Assisted Development: Claude Code can interact with your running game via MCP tools
  • Comprehensive Examples: Includes demos showing BRP capabilities
  • Full Documentation: Detailed guides for effective AI collaboration

๐Ÿš€ Quick Start

Prerequisites

  • Rust (latest stable) - Install here
  • Claude Code CLI - Install guide
  • Bevy 0.16+ - This project requires Bevy 0.16 for full BRP support

Installation

# Clone the repository
git clone https://github.com/your-username/bevy-mcp-ref.git
cd bevy-mcp-ref
 
# Run the game with BRP enabled
cargo run --features brp
 
# OR use the justfile for convenience (if you have just installed)
just demo

The game will start with BRP listening on localhost:15702.

๐Ÿ’ก Tip: This project includes a justfile with convenient commands. Install just and run just to see all available commands.

Running Examples

# Basic scene without BRP
cargo run --example basic_scene
# OR: just example-basic
 
# Interactive BRP demo
cargo run --example brp_demo --features brp
# OR: just demo

๐Ÿค– AI-Assisted Development

MCP Integration

The Bevy Remote Protocol (BRP) MCP server provides Claude Code with direct access to your running game. This project uses bevy_brp_extras for extended functionality including component mutation. Available tools include:

  • Entity Management: bevy_spawn, bevy_destroy, bevy_query
  • Component Operations: bevy_get, bevy_insert, bevy_mutate_component (via bevy_brp_extras)
  • Resource Access: bevy_get_resource, bevy_mutate_resource (via bevy_brp_extras)
  • Discovery: bevy_list, bevy_registry_schema
  • Monitoring: bevy_get_watch, brp_list_logs

Note: The bevy_brp_extras plugin includes RemotePlugin and RemoteHttpPlugin internally, providing full mutation support beyond base BRP capabilities.

Example Workflow

  1. Start your game:

    cargo run --features brp
  2. Ask Claude to inspect it:

    โ€œShow me all entities with Transform componentsโ€

  3. Make live changes:

    โ€œMake the green sphere jump twice as highโ€

  4. Test ideas without recompiling:

    โ€œSpawn a golden sphere at position (5, 0, 0) with a metallic materialโ€

  5. Finalize code:

    โ€œUpdate the code with the changes that workedโ€

๐Ÿ“š Documentation

๐ŸŽฏ Project Structure

bevy-mcp-ref/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ main.rs              # Main game with BRP enabled
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ basic_scene.rs       # Simple Bevy scene
โ”‚   โ””โ”€โ”€ brp_demo.rs          # Interactive BRP demonstration
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ BRP_MCP_GUIDE.md     # Complete MCP tools reference
โ”‚   โ””โ”€โ”€ EXAMPLES.md          # Practical examples
โ”œโ”€โ”€ assets/                  # Game assets (empty initially)
โ”œโ”€โ”€ CLAUDE.md                # AI assistant instructions
โ”œโ”€โ”€ Cargo.toml               # Project dependencies
โ””โ”€โ”€ README.md                # This file

๐Ÿ”ง Development

Quick Commands with justfile

This project includes a justfile for convenient development commands:

# See all available commands
just
 
# Run the interactive demo
just demo
 
# Run with auto-reload on file changes
just watch-demo
 
# Full quality check (format, lint, test, build)
just check-all
 
# Production build with all checks
just prod

Building

# Debug build (with dynamic linking for faster compile)
cargo build
# OR: just build
 
# Debug build with BRP
cargo build --features brp
# OR: just build-brp
 
# Release build
cargo build --release --features brp
# OR: just build-release

Testing

# Run tests
cargo test
# OR: just test
 
# Check code
cargo check --all-features
# OR: just check

Linting

# Format code
cargo fmt
# OR: just fmt
 
# Lint
cargo clippy --all-features
# OR: just lint

Basic Scene

A simple 3D scene with rotating cube, ground plane, and camera.

cargo run --example basic_scene

BRP Interactive Demo

Immersive 3D park scene with interactive camera controls, demonstrating full BRP capabilities:

Visual Features:

  • 3 rotating spheres (red, green bouncing, blue) with smooth animations
  • Green sphere performs spectacular parabolic arc trajectory (jumps over blue sphere)
  • 5 trees with brown trunks and green foliage in circular arrangement
  • 8 decorative rocks scattered naturally around the scene
  • Grass-colored 25x25 ground plane
  • Bright ambient lighting (500 brightness) + 3 point lights for even illumination

Interactive Controls:

  • Press โ€˜Cโ€™ to grab cursor and enable mouse look
  • WASD - First-person movement (forward/left/back/right)
  • Mouse - Free-look camera rotation (when cursor grabbed)
  • Space - Fly up
  • Shift - Fly down
  • ESC - Release cursor

BRP Features Demonstrated:

  • Live component mutation (modify sphere bounce height in real-time)
  • Entity querying and inspection
  • Transform manipulation
  • Component registration with reflection system
  • 30+ named entities for easy MCP interaction
cargo run --example brp_demo --features brp

Pro Tip: Use the camera controls to explore the scene from different angles and watch the green sphereโ€™s parabolic jump from various perspectives!

๐Ÿ› ๏ธ MCP Tools Quick Reference

Check if game is running

mcp__brp__brp_status({ app_name: "bevy-mcp-ref" })

Query all entities

mcp__brp__bevy_query({
  data: { components: ["bevy_transform::components::transform::Transform"] },
  filter: {}
})

Spawn a sphere

mcp__brp__bevy_spawn({
  components: {
    "bevy_transform::components::transform::Transform": {
      "translation": [0.0, 5.0, 0.0],
      "rotation": [0.0, 0.0, 0.0, 1.0],
      "scale": [1.0, 1.0, 1.0]
    },
    "bevy_core::name::Name": "My Sphere"
  }
})

Move an entity

mcp__brp__bevy_mutate_component({
  entity: 123,
  component: "bevy_transform::components::transform::Transform",
  path: ".translation.y",
  value: 10.0
})

See EXAMPLES.md for more examples!

๐Ÿ” Key Concepts

Bevy Remote Protocol (BRP)

BRP is a JSON-RPC interface that allows external tools to:

  • Query entity-component data
  • Modify component values (requires bevy_brp_extras for full mutation support)
  • Spawn and destroy entities
  • Access global resources
  • Monitor changes in real-time

This project uses bevy_brp_extras (v0.1+) which extends base BRP with:

  • bevy/mutate_component - Modify specific component fields without replacing entire components
  • bevy/mutate_resource - Modify specific resource fields
  • Full reflection support for custom components

Entity-Component-System (ECS)

Bevy uses ECS architecture:

  • Entities: Unique identifiers for game objects
  • Components: Data attached to entities (Transform, Camera, etc.)
  • Systems: Functions that process entities with specific components

MCP Integration

The MCP server bridges Claude Code and BRP:

  1. You run your Bevy game with RemotePlugin
  2. BRP listens on port 15702
  3. Claude Code uses MCP tools to send BRP commands
  4. Your game responds with data or applies changes

๐Ÿ’ก Why This Matters

Traditional game development workflow:

  1. Write code
  2. Compile (can take minutes)
  3. Run game
  4. Test
  5. Repeat

With BRP + MCP workflow:

  1. Run game once
  2. Test ideas via live editing (change sphere height from 5.0 โ†’ 12.0 in seconds!)
  3. Experiment freely (move objects, change colors, spawn entities)
  4. Finalize code based on what works
  5. Minimal compilation needed

Real Example: In this demo, we modified the green sphereโ€™s bounce height from 5.0 to 8.0 to 12.0 all while the game was running - no recompilation required!

Result: Faster iteration, more experimentation, better games!

๐Ÿค Contributing

This is a reference implementation. Feel free to:

  • Fork and customize for your projects
  • Add examples demonstrating new BRP capabilities
  • Improve documentation
  • Share your AI-assisted development workflows

๐Ÿ“„ License

MIT License - See LICENSE file for details

๐Ÿ”— Resources

๐ŸŽ“ Learning Path

  1. Start here: Run cargo run --example brp_demo --features brp
  2. Read: BRP_MCP_GUIDE.md
  3. Try: Examples from EXAMPLES.md
  4. Experiment: Ask Claude to help you build features
  5. Build: Create your own game with AI assistance!

Built with โค๏ธ using Bevy and Claude Code

Happy AI-assisted game development! ๐ŸŽฎ๐Ÿค–