MCP Tools Reference
The Physics Sandbox MCP server exposes 59 tools that AI assistants (Claude, GPT, etc.) can
call over the Model Context Protocol to control a live physics simulation. Tools are
registered automatically at startup via WithToolsFromAssembly() and communicate with
the physics server over gRPC.
Nullable<T> (not F# Option<T>)
for correct JSON schema generation by the MCP framework.
This page documents every tool grouped by category.
Summary Table
Simulation Tools
Core simulation commands for adding bodies, applying forces, and controlling playback.
Defined in SimulationTools.fs.
add_body
Add a rigid body (sphere or box) to the physics simulation at the specified position.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
(required) |
Body shape: |
|
float |
0.5 |
Sphere radius (required if shape=sphere) |
|
float |
0.5 |
Box half-extent X (required if shape=box) |
|
float |
0.5 |
Box half-extent Y (required if shape=box) |
|
float |
0.5 |
Box half-extent Z (required if shape=box) |
|
float |
0.0 |
Position X |
|
float |
5.0 |
Position Y |
|
float |
0.0 |
Position Z |
|
float |
1.0 |
Body mass (0 = static) |
A unique body ID is auto-generated from the shape name (e.g., sphere-1, box-2).
// Example: add a sphere at position (0, 10, 0) with mass 2
// add_body shape="sphere" radius=0.5 x=0 y=10 z=0 mass=2
apply_force
Apply a continuous force vector to a body. The force persists across simulation steps
until cleared with clear_forces.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
(required) |
Target body ID |
|
float |
0.0 |
Force X component |
|
float |
0.0 |
Force Y component |
|
float |
0.0 |
Force Z component |
apply_impulse
Apply an instantaneous impulse to a body, immediately changing its velocity.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
(required) |
Target body ID |
|
float |
0.0 |
Impulse X component |
|
float |
0.0 |
Impulse Y component |
|
float |
0.0 |
Impulse Z component |
apply_torque
Apply a rotational torque to a body around the specified axis vector.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
(required) |
Target body ID |
|
float |
0.0 |
Torque X component |
|
float |
0.0 |
Torque Y component |
|
float |
0.0 |
Torque Z component |
set_gravity
Set the global gravity vector for the simulation.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
float |
0.0 |
Gravity X |
|
float |
-9.81 |
Gravity Y |
|
float |
0.0 |
Gravity Z |
step
Advance the physics simulation by a single time step. No parameters.
play
Start continuous simulation playback, stepping automatically each frame. No parameters.
pause
Pause continuous simulation playback, freezing all bodies in place. No parameters.
remove_body
Remove a body from the simulation by its identifier.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
(required) |
Body ID to remove |
clear_forces
Clear all accumulated continuous forces on a body.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
(required) |
Body ID |
restart_simulation
Reset the entire simulation: removes all bodies, clears forces, and resets time to zero. Performance metrics persist across restarts. No parameters.
View Tools
Controls for the 3D Stride viewer: camera positioning, zoom, and wireframe rendering.
Defined in ViewTools.fs.
set_camera
Set the 3D viewer camera position and look-at target.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
float |
0.0 |
Camera position X |
|
float |
10.0 |
Camera position Y |
|
float |
20.0 |
Camera position Z |
|
float |
0.0 |
Look-at target X |
|
float |
0.0 |
Look-at target Y |
|
float |
0.0 |
Look-at target Z |
set_zoom
Set the 3D viewer zoom level.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
float |
(required) |
Zoom level (1.0 = default) |
toggle_wireframe
Toggle wireframe rendering mode on or off in the 3D viewer. No parameters.
Preset Tools
Preset body types with realistic physical dimensions and masses.
Defined in PresetTools.fs. All presets share a common parameter set.
Common parameters for all preset tools:
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
float |
0.0 |
X position |
|
float |
0.0 |
Y position |
|
float |
0.0 |
Z position |
|
float |
(varies) |
Mass override (uses preset default if <= 0) |
|
string |
(auto) |
Custom body ID (auto-generated if empty) |
add_marble
Add a marble: a tiny sphere with radius 0.01 and default mass 0.005 kg.
add_bowling_ball
Add a bowling ball: a dense sphere with radius 0.11 and default mass 6.35 kg.
add_beach_ball
Add a beach ball: a large, lightweight sphere with radius 0.2 and default mass 0.1 kg.
add_crate
Add a crate: a 1x1x1 box (0.5 half-extents) with default mass 20 kg.
add_brick
Add a brick: a flat rectangular box (0.2x0.1x0.05 half-extents) with default mass 3 kg.
add_boulder
Add a boulder: a heavy sphere with radius 0.5 and default mass 200 kg.
add_die
Add a die: a tiny cube (0.05 half-extents) with default mass 0.03 kg.
Generator Tools
Procedural body arrangement generators for quickly populating the simulation.
Defined in GeneratorTools.fs.
generate_random_bodies
Generate a random mix of spheres and boxes with randomized positions, sizes, and masses within a bounded volume.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
int |
(required) |
Number of bodies to create |
|
int |
0 |
Random seed (0 for non-deterministic) |
generate_stack
Generate a vertical stack of unit-sized crates at the specified base position, each spaced 1 unit apart vertically.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
int |
(required) |
Number of crates in the stack |
|
float |
0.0 |
Base X position |
|
float |
0.0 |
Base Y position |
|
float |
0.0 |
Base Z position |
generate_row
Generate a horizontal row of spheres along the X axis.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
int |
(required) |
Number of spheres in the row |
|
float |
0.0 |
Start X position |
|
float |
0.0 |
Y position |
|
float |
0.0 |
Z position |
|
float |
0.5 |
Spacing between sphere centers |
generate_grid
Generate a 2D grid of crates on the XZ plane with 1-unit spacing between centers.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
int |
(required) |
Number of rows |
|
int |
(required) |
Number of columns |
|
float |
0.0 |
Start X position |
|
float |
0.5 |
Y position |
|
float |
0.0 |
Start Z position |
generate_pyramid
Generate a pyramid of crates with the widest layer at the base, narrowing by one crate per layer.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
int |
(required) |
Number of layers |
|
float |
0.0 |
Base X position |
|
float |
0.0 |
Base Y position |
|
float |
0.0 |
Base Z position |
Steering Tools
High-level body movement using compass directions and target-based launching.
Defined in SteeringTools.fs.
push_body
Push a body with an impulse in one of six compass directions: up, down, north,
south, east, west.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
(required) |
Body ID to push |
|
string |
(required) |
Direction: up, down, north, south, east, west |
|
float |
10.0 |
Impulse magnitude |
launch_body
Launch a body toward a target position. Computes the direction vector from the body's current position and applies a normalized impulse at the given speed.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
(required) |
Body ID to launch |
|
float |
(required) |
Target X |
|
float |
(required) |
Target Y |
|
float |
(required) |
Target Z |
|
float |
10.0 |
Launch speed |
spin_body
Apply a rotational torque to spin a body around a compass-direction axis.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
(required) |
Body ID to spin |
|
string |
(required) |
Axis direction: up, down, north, south, east, west |
|
float |
10.0 |
Torque magnitude |
stop_body
Stop a body by clearing its forces and applying an opposing impulse proportional to its current momentum to cancel its velocity.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
(required) |
Body ID to stop |
Batch Tools
Batch command submission for reducing round-trip overhead. Accepts JSON arrays of
commands and sends them in a single gRPC call. Defined in BatchTools.fs.
batch_commands
Submit multiple simulation commands in a single batch. Each element in the JSON array
must have a type field identifying the command.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
(required) |
JSON array of commands |
Supported command types: add_body, apply_force, apply_impulse, step, play,
pause, set_gravity, remove_body, clear_forces, reset.
// Example JSON for batch_commands:
// [
// {"type":"add_body","shape":"sphere","radius":0.5,"x":0,"y":5,"z":0,"mass":1},
// {"type":"add_body","shape":"box","hx":0.5,"hy":0.5,"hz":0.5,"x":2,"y":5,"z":0,"mass":5},
// {"type":"step"},
// {"type":"step"}
// ]
batch_view_commands
Submit multiple view commands in a single batch.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
(required) |
JSON array of view commands |
Supported command types: set_camera, set_zoom, toggle_wireframe.
// Example JSON for batch_view_commands:
// [
// {"type":"set_camera","px":0,"py":10,"pz":20,"tx":0,"ty":0,"tz":0},
// {"type":"set_zoom","level":1.5}
// ]
Query Tools
Tools for querying simulation state and server connection health.
Defined in QueryTools.fs.
get_state
Get the current simulation state including all body positions, velocities, masses, and shapes. Returns cached data from the background gRPC state stream. No parameters.
The output includes a formatted table of all bodies with their ID, position, velocity, mass, and shape.
get_status
Get MCP server connection status and health. Reports the state of the gRPC state stream, view command stream, and audit stream, along with data staleness. No parameters.
Metrics Tools
Performance monitoring tools for message counts, data volumes, and pipeline timing.
Defined in MetricsTools.fs.
get_metrics
Fetch performance metrics from all services (Server, Simulation, Viewer, MCP) including message counts, byte volumes, and pipeline timing breakdowns. No parameters.
get_diagnostics
Fetch pipeline diagnostics showing the timing breakdown across four stages: simulation tick, serialization, gRPC transfer, and rendering. Highlights the slowest bottleneck stage. No parameters.
Audit Tools
Command audit trail for debugging and replay. Defined in AuditTools.fs.
get_command_log
Retrieve the most recent command events from the audit stream, formatted with human-readable descriptions of each simulation or view command.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
int |
20 |
Maximum number of entries to return |
Stress Test Tools
Background stress tests for measuring simulation performance limits.
Defined in StressTestTools.fs.
start_stress_test
Start a background stress test. Returns a test ID that can be polled with
get_stress_test_status.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
(required) |
Scenario: |
|
int |
500 |
Maximum bodies for body-scaling scenario |
|
int |
30 |
Duration for command-throughput scenario |
Scenarios:
- body-scaling -- Adds bodies incrementally until performance degrades, measuring the simulation's body count limit.
- command-throughput -- Measures the maximum command processing rate over a fixed duration.
get_stress_test_status
Get the status, progress, and results of a running or completed stress test.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
(required) |
Test ID returned by |
Comparison Tools
Performance comparison between direct gRPC scripting and MCP command paths.
Defined in ComparisonTools.fs.
start_comparison_test
Run a three-phase comparison test that executes the same workload (add N bodies, step M
times) via direct gRPC calls and batched MCP calls, measuring timing differences and
overhead. Returns a test ID -- poll with get_stress_test_status.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
int |
100 |
Number of bodies to add in each path |
|
int |
60 |
Number of simulation steps in each path |
See Also
- Architecture Overview -- system design and gRPC message flow
- Demo Scripts -- F# and Python demo scripts that exercise these tools
- Getting Started -- build, run, and connect to the sandbox
PhysicsSandbox