mcp and non-WebAssembly only.Expand description
The MCP service: the tool router, the shared argument types and the transport.
Each tool turns its JSON arguments into a McpCommand and sends it to the thread that owns the world. The tool then awaits the result: structured JSON for most tools, an image or audio content block for the ones that read pixels or samples back inline, and a written path for the ones that save to a file. A tool that fails returns a tool-level error result rather than a protocol error, so a model sees the message instead of a transport failure.
The router starts empty and the engine crates fill it in: a crate submits a
ToolSource whose extend registers the tools that crate defines. The
server therefore carries tools this crate knows nothing about, and a tool
whose types live elsewhere still runs against the world through the same
command channel.
Re-exportsΒ§
use std::error::Error;πuse std::future::Future;πuse std::sync::Arc;πuse rmcp::handler::server::tool::schema_for_input;πuse rmcp::handler::server::wrapper::Parameters;πuse rmcp::model::CallToolResponse;πuse rmcp::model::CallToolResult;πuse rmcp::model::ContentBlock;πuse rmcp::model::ServerCapabilities;πuse rmcp::model::ServerConfig;πuse rmcp::model::Tool;πuse rmcp::ErrorData;πuse rmcp::ServerHandler;πuse rmcp::tool_handler;πuse schemars::JsonSchema;πuse schemars::JsonSchema;πuse serde::Deserialize;πuse serde::Deserialize;πuse serde::de::DeserializeOwned;πuse serde_json::Value;πuse crate::mcp::host::McpCommand;πuse crate::mcp::host::Output;πuse crate::mcp::host::WorldId;πuse crate::Entity;πuse crate::World;π
StructsΒ§
- Context
Arg - Which world and render context a GPU tool runs against.
- Create
Mesh - Arguments for creating a mesh.
- Entity
Arg - Arguments for one entity in a world.
- GetComponent
- Arguments for reading one component.
- Handle
Arg - Which world and resource a handle tool runs against.
- Input
Arg - Arguments for reading or sending input.
- List
Entities - Arguments for listing entities.
- Load
Gltf - Arguments for load_gltf.
- McpServer
- The MCP server driving one or more worlds.
- Mesh
Transform - A transform as JSON.
- NoArgs
- No arguments.
- Read
Buffer - Arguments for reading a buffer.
- Renderer
Arg - Arguments for rendering a frame.
- Save
Buffer - Arguments for saving a buffer to a file.
- Save
Screenshot - Arguments for saving a screenshot as an image.
- Save
Texture - Arguments for saving a texture as an image.
- Screenshot
- Arguments for taking a screenshot.
- Send
Input - Arguments for sending input events.
- SetComponent
- Arguments for writing one component.
- Spawn
Entity - Arguments for spawning an entity.
- Tool
Route - Tool
Router - Tool
Source - A crateβs contribution to the serverβs tool set.
- World
Arg - Which world a tool runs against.
FunctionsΒ§
- command
- Send a job to the world
worldnames and await its JSON result. - default_
limit π - entity
- An entity handle from the
u64bits a JSON argument carries. - identity4 π
- one3 π
- run
- Send a job to the world
worldnames and await its output. - send
- Send a job to the world
worldnames and await what it answered. - serve_
stdio_ with - Serve MCP over stdio, handing every command to
sink. - serve_
with - Serve MCP over any transport, handing every command to
sink. - tool
- A tool route from a name, a description and an asynchronous handler.
- zero3 π
Type AliasesΒ§
- Command
Sender - The channel a tool sends its commands over.
- Tool
Result - What a tool handler answers with.