unlit_ecs/mcp/mod.rs
1//! The [Model Context Protocol](https://modelcontextprotocol.io) server and the
2//! tools a world answers through it.
3//!
4//! A [World](crate::World) is not `Send`, so it stays on the thread that owns
5//! it; the protocol runs on its own tokio thread and the two meet at an
6//! [McpCommand] carrying the [WorldId] of the
7//! world it should run against.
8//!
9//! The tools themselves live in the crates that define the types they read. A
10//! crate submits a [ToolSource], whose `extend` registers that crate's tools;
11//! [McpServer] calls every submission while it is built. The server therefore
12//! carries the ECS tools from this crate, the rendering tools from
13//! [unlit3d](https://docs.rs/unlit3d), and any tool another crate adds, without
14//! depending on any of them. Not built on wasm, where a browser drives the world
15//! directly rather than through this protocol.
16
17pub mod host;
18mod server;
19mod tools;
20
21pub use crate::reflect::{
22 ComponentEntry, ComponentError, contains, current_partial, default_partial, encode_json,
23 entries, entry, names, push, push_json, set, set_json,
24};
25pub use host::{
26 Despawned, EncodedAudio, EncodedImage, Job, McpCommand, Output, SavedFile, SpawnedEntity,
27 WorldEntry, WorldId, extension_of, saved_name, to_value, with_extension, write_file,
28};
29pub use inventory;
30pub use server::{
31 CommandSender, ContextArg, CreateMesh, EntityArg, GetComponent, HandleArg, InputArg,
32 ListEntities, LoadGltf, McpServer, MeshTransform, NoArgs, ReadBuffer, RendererArg, SaveBuffer,
33 SaveScreenshot, SaveTexture, Screenshot, SendInput, SetComponent, SpawnEntity, ToolResult,
34 ToolRouter, ToolSource, WorldArg, command, entity, run, send, serve_stdio_with, serve_with,
35 tool,
36};
37
38/// The JSON crate a tool uses to build structured output.
39pub use serde_json;