Skip to main content

Module mcp

Module mcp 

Source
Available on crate feature mcp and non-WebAssembly only.
Expand description

The Model Context Protocol server and the tools a world answers through it.

A World is not Send, so it stays on the thread that owns it; the protocol runs on its own tokio thread and the two meet at an McpCommand carrying the WorldId of the world it should run against.

The tools themselves live in the crates that define the types they read. A crate submits a ToolSource, whose extend registers that crate’s tools; McpServer calls every submission while it is built. The server therefore carries the ECS tools from this crate, the rendering tools from unlit3d, and any tool another crate adds, without depending on any of them. Not built on wasm, where a browser drives the world directly rather than through this protocol.

Re-exports§

pub use crate::reflect::ComponentEntry;
pub use crate::reflect::ComponentError;
pub use crate::reflect::contains;
pub use crate::reflect::current_partial;
pub use crate::reflect::default_partial;
pub use crate::reflect::encode_json;
pub use crate::reflect::entries;
pub use crate::reflect::entry;
pub use crate::reflect::names;
pub use crate::reflect::push;
pub use crate::reflect::push_json;
pub use crate::reflect::set;
pub use crate::reflect::set_json;
pub use host::Despawned;
pub use host::EncodedAudio;
pub use host::EncodedImage;
pub use host::Job;
pub use host::McpCommand;
pub use host::Output;
pub use host::SavedFile;
pub use host::SpawnedEntity;
pub use host::WorldEntry;
pub use host::WorldId;
pub use host::extension_of;
pub use host::saved_name;
pub use host::to_value;
pub use host::with_extension;
pub use host::write_file;
pub use server::CommandSender;
pub use server::ContextArg;
pub use server::CreateMesh;
pub use server::EntityArg;
pub use server::GetComponent;
pub use server::HandleArg;
pub use server::InputArg;
pub use server::ListEntities;
pub use server::LoadGltf;
pub use server::McpServer;
pub use server::MeshTransform;
pub use server::NoArgs;
pub use server::ReadBuffer;
pub use server::RendererArg;
pub use server::SaveBuffer;
pub use server::SaveScreenshot;
pub use server::SaveTexture;
pub use server::Screenshot;
pub use server::SendInput;
pub use server::SetComponent;
pub use server::SpawnEntity;
pub use server::ToolResult;
pub use server::ToolSource;
pub use server::WorldArg;
pub use server::command;
pub use server::entity;
pub use server::run;
pub use server::send;
pub use server::serve_stdio_with;
pub use server::serve_with;
pub use server::tool;
pub use inventory;
pub use serde_json;

Modules§

host
The world side of the MCP server.
server 🔒
The MCP service: the tool router, the shared argument types and the transport.
tools 🔒
The ECS tools: reading and writing a world’s entities and components.

Structs§

ToolRouter