cua-spaces: agents and MCP
Agents in Spaces and the Spaces MCP server (stdio and HTTP).
Agents in Spaces and the Spaces MCP server (stdio and HTTP).
Part of the public API of the cua-spaces crate (cua_spaces): agents and MCP. Summaries and declarations only (cargo doc -p cua-spaces --open in libs/cua has the full comments); see Rust crates for stability.
More of this crate: registry and primitives, client.
agents: Coding agents inside a Space: cua_agents over the ...mcp: The Spaces MCP server: the contract's tools over ...mcp::codes: JSON-RPC error codes.mcp::http: MCP streamable HTTP: POST /mcp with a JSON-RPC body ...mcp::stdio: MCP over stdio: newline-delimited JSON-RPC.agents::CapabilitiesReport#agent_capabilities.
pub struct CapabilitiesReport {
pub protocol: &'static str,
pub statuses: Vec<&'static str>,
pub event_kinds: &'static [&'static str],
pub harnesses: Vec<HarnessInfo>,
pub forwardable_env: Vec<&'static str>,
pub runner: &'static str,
}mcp::McpServer#The server.
pub struct McpServer { /* private fields */ }
impl McpServer {
fn new(spaces: Spaces) -> Self;
fn remote(backend: Arc<dyn ToolBackend>) -> Self;
fn with_session_broker(self, broker: Arc<dyn SessionBroker>) -> Self;
fn with_extension(self, extension: Arc<dyn ToolExtension>) -> Self;
fn with_filter(self, filter: ToolFilter) -> Self;
fn with_name(self, name: &'static str) -> Self;
fn with_instructions(self, instructions: &'static str) -> Self;
fn spaces(&self) -> Option<&Spaces>;
fn tools_list(&self) -> Value;
async fn call(&self, name: &str, arguments: Value) -> ToolOutcome;
async fn handle(&self, message: Value) -> Option<Value>;
}mcp::ToolBackend#Where contract tool calls go when the server does not ...
pub trait ToolBackend: Send + Sync {
async fn call(&self, tool: &str, arguments: Value) -> ToolOutcome;
}mcp::ToolExtension#Tools served next to the Spaces contract (the cua ...
pub trait ToolExtension: Send + Sync {
fn tools(&self) -> Vec<Value>;
async fn call(&self, tool: &str, arguments: Value) -> Option<ToolOutcome>;
}mcp::ToolOutcome#The result of one tool call, as MCP content.
pub struct ToolOutcome {
pub content: Vec<Value>,
pub structured: Option<Value>,
pub is_error: bool,
pub meta: Option<Value>,
}
impl ToolOutcome {
fn text(text: impl Into<String>) -> Self;
fn json<T: Serialize>(value: &T) -> Self;
fn error(e: &Error) -> Self;
fn error_message(kind: &str, message: impl Into<String>) -> Self;
fn first_text(&self) -> Option<&str>;
fn to_result(&self) -> Value;
}// mod agents
/// What every harness is, can and cannot ...
pub fn capabilities() -> CapabilitiesReport
/// Resolves `names` from this process's ...
pub fn env_from_host(names: &[String]) -> Result<(BTreeMap<String, String>, Vec<String>)>
/// The provider key variables a host may ...
pub fn forwardable_env() -> Vec<&'static str>
// mod mcp
/// Runs a Space-scoped contract tool ...
pub async fn call_on(space: &Space, tool: &str, arguments: Value) -> ToolOutcome
// mod mcp::http
/// The `/mcp` router.
pub fn router(server: McpServer, bearer: Option<String>) -> Router
/// Serves `router` on `listener` until the ...
pub async fn serve(server: McpServer, listener: TcpListener, bearer: Option<String>) -> Result<()>
// mod mcp::stdio
/// Serves until `input` reaches EOF.
pub async fn serve<R, W>(server: McpServer, input: R, output: W) -> Result<()> where R: AsyncRead + Unpin, W: AsyncWrite + Unpin + Send + 'static
/// Serves on the process's stdin/stdout.
pub async fn serve_process_stdio(server: McpServer) -> Result<()>// mod mcp
/// Server instructions sent in ...
pub const INSTRUCTIONS: &str = /* ... */;
/// Server name in `initialize`.
pub const SERVER_NAME: &str = "cua-spaces";
/// Server version in `initialize`.
pub const SERVER_VERSION: &str = "0.1.0";
/// Tools `call_on` accepts.
pub const SPACE_SCOPED_TOOLS: &[&str] = _;
/// Protocol revisions this server accepts ...
pub const SUPPORTED_PROTOCOL_VERSIONS: [&str; 3] = _;
// mod mcp::codes
/// `tools/call` without a tool `name`.
pub const INVALID_PARAMS: i64 = -32602;
/// The message is not a JSON-RPC request ...
pub const INVALID_REQUEST: i64 = -32600;
/// An unknown method, or `tools/call` of a ...
pub const METHOD_NOT_FOUND: i64 = -32601;
/// The message is not valid JSON.
pub const PARSE_ERROR: i64 = -32700;
// mod mcp::http
/// Largest accepted request body (16 MiB).
pub const MAX_BODY_BYTES: usize = _;
/// Session header.
pub const SESSION_HEADER: &str = "mcp-session-id";
// mod mcp::stdio
/// Longest accepted message line (16 MiB).
pub const MAX_LINE_BYTES: usize = _;// mod mcp
/// Which contract tools a server exposes ...
pub type ToolFilter = Arc<dyn Fn(&str) -> bool + Send + Sync>;cua_agents::AgentEvent, cua_agents::Agents, cua_agents::Artifact, cua_agents::Attachment, cua_agents::Endpoint, cua_agents::EventPage, cua_agents::events, cua_agents::harness, cua_agents::installables, cua_agents::McpServer, cua_agents::quote, cua_agents::RunInfo, cua_agents::RunOptions, cua_agents::RunResult, cua_agents::runs, cua_agents::RunStatus, cua_agents::Started, cua_agents::transcript, cua_agents::Transcript, cua_agents::TranscriptItem, cua_agents::Wire.