Available on crate feature
mcp and non-WebAssembly only.Expand description
The world side of the MCP server.
A World is not Send, and the work that reads it must happen on the thread that owns it. The MCP transport, on the other hand, runs on a tokio thread. The two meet at a command channel: a tool builds an McpCommand holding a closure and the WorldId of the world it should run against, the thread that owns that world resolves the id and calls McpCommand::dispatch, and the Output travels back on the commandβs reply channel.
Nothing here assumes how many worlds there are or what a world contains. A crate that defines tools of its own submits a ToolSource and keeps its tool bodies next to the types they read; this module carries only the contract every tool shares.
Re-exportsΒ§
use std::panic::AssertUnwindSafe;πuse std::path::Path;πuse schemars::JsonSchema;πuse schemars::JsonSchema;πuse serde::Deserialize;πuse serde::Deserialize;πuse serde_json::Value;πuse crate::Entity;πuse crate::World;πpub use crate::naming::extension_of;pub use crate::naming::with_extension;
StructsΒ§
- Despawned
- What a despawn removed.
- Encoded
Audio - A sound the transport sends as an audio content block.
- Encoded
Image - An image the transport sends as an image content block.
- McpCommand
- A request together with the channel its result is sent back on.
- Saved
File - A file a save tool wrote.
- Spawned
Entity - A spawned entity, as the tools report it.
- World
Entry - One world a host reports, with the name it was spawned under.
EnumsΒ§
- Output
- What a finished job produced.
- Request π
- What a command asks the host to do.
- WorldId
- Which world a tool or a command runs against.
FunctionsΒ§
- catch_
job π - Run one tool job, catching a panic into an error reply.
- generated_
name π - The name a save writes when its caller named none:
stemwith a fresh random id, so a save never overwrites the file an earlier one wrote. - panic_
message π - The message a panic payload carries, with a fallback for foreign payloads.
- saved_
name - The name a save writes: the callerβs own, given
extensionwhen it carries none, or a freshstemname when the caller named none. - to_
value - Serialise a value through the reflection it derives.
- write_
file - Write
bytestodirectory/file_name, creating the directory.
Type AliasesΒ§
- Job
- A unit of work for the thread that owns a world.