mcp-physics-bridge
Supports local Ollama models as an LLM provider, enabling offline or self-hosted AI reasoning and physics intent mapping.
Allows the integration of OpenAI LLM as a provider for probabilistic AI reasoning, translating language prompts into physics intent and animation synthesis.
Exposes Prometheus metrics endpoints for monitoring request counts, memory usage, and service health.
Supports browser-based engines like Three.js via authenticated WebSocket, enabling 60 FPS physics updates and visual visualizer integration.
Provides integration with Unity games via gRPC streaming, enabling real-time physics state exchange and AI-driven physics operations.
Enables Unreal Engine 5 integration through gRPC streams, converting actor data to flat SoA buffers and applying AI-modified physics states.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-physics-bridgeRun a 60fps ragdoll fall on the character and report joint forces"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-physics-bridge
Table of Contents
Related MCP server: flash-cast-mcp
Core Highlights
Architecture Overview
+-------------------------------------------------------------+
| Game Engine |
| (Unity / Unreal / Godot / Phaser / Custom) |
+-------------------------------------------------------------+
| ^
| [Native: HTTP/2 gRPC Stream] |
| [Web: WebSocket (Token Auth)] | [Blend Weights /
v | Playback Scale]
+----------------------------------------------------+--------+
| mcp-physics-bridge | |
| v |
| +------------------------+ +-------------------------+ |
| | Data Translation Layer| | AI-to-Rig Synthesizer | |
| | (SoA <-> Scene Tree) | | (Intent / Priority) | |
| +------------------------+ +-------------------------+ |
| | ^ |
| v | |
| +------------------------+ +-------------------------+ |
| | State Authority Guard | | In-Memory Wasm Sandbox | |
| | (Playtest vs Debug) |--->| (AssemblyScript Engine) | |
| +------------------------+ +-------------------------+ |
| | ^ |
| v | |
| +------------------------+ +-------------------------+ |
| | Keyframe RAG Store | | Model Context Protocol | |
| | (SQLite-Vector) | | (BYOK LLM Provider) | |
| +------------------------+ +-------------------------+ |
+-------------------------------------------------------------+Quickstart (Zero Configuration)
You can run mcp-physics-bridge immediately via npx without cloning or manual builds:
# Run stdio MCP server for Claude Desktop, Cursor, or Antigravity
npx -y mcp-physics-bridge --stdio
# Run full multi-protocol server daemon (gRPC + gRPC-Web + WebSocket + MCP)
npx -y mcp-physics-bridgeZero-Friction Developer Experience: No API keys are required to get started. The server automatically falls back to an offline deterministic mock LLM provider and dynamically generates a cryptographically secure 256-bit runtime token (data/.runtime_token) if unconfigured.
AI Editor Integration
Claude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"physics-bridge": {
"command": "npx",
"args": ["-y", "mcp-physics-bridge", "--stdio"],
"env": {
"MCP_PHYSICS_AUTHORITY_MODE": "playtest",
"MCP_PHYSICS_BYOK_PROVIDER": "mock"
}
}
}
}Cursor / Antigravity (~/.cursor/mcp.json or .agy/settings.json)
{
"mcpServers": {
"physics-bridge": {
"command": "npx",
"args": ["-y", "mcp-physics-bridge", "--stdio"]
}
}
}CLI Flags & Daemon Mode
mcp-physics-bridge [OPTIONS]
MODES:
--stdio Run in stdio MCP mode (for Claude Desktop / Cursor)
--all Run full multi-protocol daemon [default]
OPTIONS:
-p, --port <port> WebSocket physics port (default: 8080)
--grpc <port> Native HTTP/2 gRPC streaming port (default: 50051)
--grpc-web <port> gRPC-Web proxy / metrics port (default: 50052)
--env <env> Environment mode: 'development' | 'production'
--fps <number> Target simulation tick rate (default: 60)
-v, --version Print version and exit
-h, --help Show help screenGame Engine Integrations
The examples/ directory contains production-ready client scripts and schemas:
Engine | Protocol | Example Guide | Description |
Unity | HTTP/2 gRPC Stream | C# | |
Unreal Engine 5 | HTTP/2 gRPC Stream | C++ Actor Component converting Actor data to flat SoA. | |
Godot 4 | WebSocket (Token Auth) | GDScript | |
Web (Phaser / Three.js) | WebSocket | Standalone 60 FPS HTML5 Canvas visualizer. |
For instructions on compiling the canonical.proto schemas for C#, C++, GDScript, and Python, see the Client Engine Guide.
Observability & Monitoring
The bridge exposes standard cloud-native health and metrics endpoints on the gRPC-Web port (default 50052):
Health Probe (
GET /healthz):curl http://localhost:50052/healthz{ "status": "ok", "service": "mcp-physics-bridge", "uptimeSeconds": 142.5, "requestsProcessed": 42 }Prometheus Metrics (
GET /metrics):curl http://localhost:50052/metricsExposes
mcp_physics_requests_total,mcp_physics_uptime_seconds,mcp_physics_memory_heap_bytes, andmcp_physics_memory_rss_bytes.
Production Deployment
Environment Variables
Copy .env.example to .env or pass variables to your deployment container:
cp .env.example .envVariable | Default | Description |
|
| Set to |
|
| Native engine HTTP/2 gRPC streaming port. |
|
| Browser gRPC-Web proxy & metrics port. |
|
| Web physics WebSocket port. |
| (auto-generated) | 256-bit cryptographic secret for WebSocket handshake. |
|
| Comma-separated list of allowed CORS origins. |
|
| Maximum concurrent WebSocket connections. |
|
| WebSocket frame size limit. |
|
| HTTP / gRPC-Web request body ceiling. |
|
| BYOK LLM provider: |
Docker & Docker Compose
Run the production multi-stage container with non-root security and healthcheck probes:
# Build and run with Docker
npm run docker:build
npm run docker:run
# Or launch with Docker Compose (includes persistent storage)
docker compose up -dDevelopment & Verification
Scripts Reference
# Run unit and integration test suite (27 test suites, 237 tests)
npm test
# Run tests with V8 code coverage report (>92% coverage)
npm run test:coverage
# Perform TypeScript static type check
npm run typecheck
# Compile AssemblyScript WebAssembly modules
npm run build:as
# Build production TypeScript distribution
npm run build
# Run comprehensive 10-phase manual verification
npm run verifyArchitecture Roadmap
Phase 1: Barebones Scaffolding & Build Contracts
Scaffold folder structure, configurations (
package.json,tsconfig.json,asconfig.json,vitest.config.ts, CI workflow).Define core interfaces and barebones stubs across all subsystems.
Phase 2: Protobuf Schema Definitions & Code Generation
Implement
physics_stream.proto(SoA layout, error status bitmasks).Implement
ai_hooks.proto(Dual-payload, AST diff, diagnostic traces).Implement
animation_stream.proto(Intents, weights, priority tags).
Phase 3: Network & Protocol-Splitting Layer
HTTP/2 gRPC server for native engines (
PhysicsStreamingService,AIHookService,AnimationSynthesisService).Token-handshake secured WebSocket server for web engines with CSWSH protection and timing-safe token validation.
gRPC-Web gateway for sporadic browser hooks with CORS and JSON fallback.
Phase 4: Struct of Arrays (SoA) & Data Translation Layer
Zero-copy TypedArray views (
Float32Array,Uint32Array).Bi-directional SoA $\leftrightarrow$ Hierarchical Scene Tree translator.
Phase 5: AssemblyScript Math Library & In-Memory Wasm Sandbox
Native in-sandbox
Vector3andQuaternionmath library.In-memory
asccompiler pipeline (<10ms execution).Dual-Payload verification (source checksum vs bytecode).
Reflective memory AST diffing and error logging.
Phase 6: State Authority & Validation Rules
Playtest Mode: Soft clamping, micro time-dilation, VFX-masked snaps.
Debug Mode: Strict hard rejection, frame-synchronized error status bitmask.
Phase 7: Context Management & SQLite-Vector RAG
SQLite-Vector embedded database initialization with custom vector similarity functions (
cosine_similarity,l2_distance,dot_product).Deterministic physics state embedder producing 128D normalized unit vectors from scene trees and flat SoA frames.
Selective keyframe event indexer (
collision,goal,state_change,failure) with cooldown throttling to prevent context bloat.Event detection helpers (inter-entity bounding sphere collisions, velocity state changes).
RAG prompt synthesis with token-efficient compact JSON state pruning (
formatRAGPromptContext).
Phase 8: AI-to-Rig Animation Synthesizer
Hybrid Intent-Mapping across 5 standardized genre templates (
Generic,Platformer,FPS,Action RPG,Vehicle), semantic synonyms dictionary, and custom dictionary mappings.Bridge-Side Action Priority Arbitration with multi-track skeletal layers (
Full Body,Lower Body,Upper Body,Additive), priority tag governance (uninterruptible,hit_reaction,death), and time-based action expiration.Opt-In Weight Streaming Calculator with configurable blend curves (
Linear,Smoothstep,S-Curve,Exponential,Instant), transition duration scaling, and strict sum-of-weights invariant $\sum w_i = 1.0$.Root Motion Procedural Playback Scaling with physics authority ($s = v_{\text{actual}} / v_{\text{nominal}}$), 3D/planar velocity decomposition, low-pass EMA smoothing, angular turn scaling, and foot sliding metrics.
Unified
AnimationSynthesizerorchestrator integrated into native HTTP/2 gRPC streaming.
Phase 9: Model Context Protocol (MCP) Server Integration
Standardized
@modelcontextprotocol/sdkintegration with full tool, resource, and prompt registrations.BYOK (Bring-Your-Own-Key) LLM router supporting OpenAI-compatible, Anthropic, Gemini, Ollama, custom proxy, and deterministic offline mock providers.
Complete MCP tool suite:
compile_and_test_physics,validate_physics_frame,deploy_dual_payload_logic,inspect_game_state,query_keyframe_history,inspect_reflective_memory,synthesize_animation,generate_physics_kernel,repair_physics_kernel.Resource endpoints under
physics://:physics://config,physics://server/status,physics://heuristics,physics://math/vector3,physics://math/quaternion,physics://animation/templates,physics://memory/failures.Standard prompts:
game_heuristics_kernel,debug_physics_failure,synthesize_character_animation.
Phase 10: Testing Suite & Verification
Comprehensive unit and integration test suite with Vitest (27 test files, 237 tests, >92% statement and line coverage).
End-to-end service lifecycle integration testing (
PhysicsBridgeService) covering multi-protocol bootstrap and graceful shutdown.Subsystem test coverage across MCP resources, prompts, reflective memory, deep hierarchy inspection, and BYOK LLM routers.
High-throughput 60 FPS performance benchmark validating sub-16ms latency budgets for 10,000 entities in Struct of Arrays (SoA).
Automated CI/CD verification (
.github/workflows/ci.yml) covering TypeScript typechecking, AssemblyScript Wasm compilation, full compilation build, and Vitest coverage reporting.
Community & Governance
Contributing Guide: Setup instructions, architecture standards, and PR guidelines.
Security Policy: Responsible vulnerability reporting and security architecture.
Code Examples: Integration guides and starter scripts for Unity, Unreal, Godot, and Web.
License: Licensed under the Apache License, Version 2.0.
This server cannot be deployed
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to control Unreal E…
Connect AI agents to Replynodes over the Model Context Protocol.
Create, test and play AI-native games through server-authoritative contracts.
Real-time planetary signal engine and Model Context Protocol (MCP) server for autonomous AI agents.
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceEnables AI agents to interact with and control Roblox Studio instances in real-time through the Model Context Protocol. It provides a unified tool for building, scripting, and manipulating 3D worlds with over 90 operations including instance management and Luau scripting.14 npm-
- AlicenseAqualityDmaintenanceA deterministic video rendering engine that enables AI agents to create programmable, reproducible videos via MCP protocol.1412 npm2MIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server enabling AI agents to author Unreal Engine 5 scenes directly, with tools for spawning actors, building PCG graphs, validating physics, generating terrain, and more through a single MCP connection.13MIT
- AlicenseAqualityAmaintenanceEnables natural language control of NVIDIA Isaac Sim through the Model Context Protocol, allowing you to create robots, build scenes, run simulations, and debug physics from any MCP-compatible IDE.4264MIT