mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-25 18:27:02 -06:00
The server answered tools/* and two fixed resources and nothing else, and
resources/templates/list returned an empty array. This adds the rest of the surface a
client can actually use, against 2025-06-18.
- prompts/list and prompts/get: five workflows (poster, icon-set, recolor,
trace-and-style, export-set) with templated arguments. A missing required argument
is -32602 and names itself.
- resources/templates/list, and resources/read for the templates: object/{id},
command/{id}, effect/{id}, swatch/{name}. Reading one thing at a time instead of
vectorcraft://document/json, which on a real document is thousands of lines an agent
pays for again on every change.
- completion/complete for prompt arguments and template variables, ranked prefix
first, capped at 100 with total and hasMore. The values are read live, so a suggested
format, effect id, command id, trace preset, swatch or object id is one the engine
has.
- logging/setLevel and notifications/message. Nothing installed a log::Log before, so
the engine's log::debug! calls went nowhere; this is the sink, silent until asked.
Installing it is vectorcraft-cli's job rather than the library's, so an embedder
that already has a logger keeps it.
docs/mcp.md gains a Protocol section with the capability table and a Not implemented
section: subscriptions, progress, cancellation, sampling, elicitation and Streamable
HTTP all need the transport to interleave reads, which this one does not — handle_line
answers a line with a reply, so it neither reads an incoming cancellation nor can write
progress before the reply it belongs to.
62 tests (50 unit, 12 property/fuzz). protocol_props.rs gained five: prompts survive
junk arguments, completion/complete never panics and always answers at most 100
string values with a consistent hasMore, every template reads or fails cleanly, and
prompts/completions/templates are swept with junk params while asserting the document
comes back byte-identical.
ROADMAP: one bullet under Automation in Shipped so far and the changelog line. The
parity table and the gap list are untouched — MCP is agent automation, so feature
parity does not move.
59 lines
1.7 KiB
Rust
59 lines
1.7 KiB
Rust
//! VectorCraft's MCP server.
|
|
//!
|
|
//! [Model Context Protocol](https://modelcontextprotocol.io) over stdio: newline-delimited
|
|
//! JSON-RPC 2.0, hand-written (no async runtime). The server exposes VectorCraft as a set of MCP
|
|
//! tools and resources and forwards everything to a [`Backend`]:
|
|
//!
|
|
//! - [`Remote`] talks to a running desktop app through its loopback JSON-lines control channel
|
|
//! (`vectorcraft --control 7979`): one `{"id","method","params"}` line in, one
|
|
//! `{"id","ok","result"|"error"}` line out.
|
|
//! - [`Headless`] hosts an in-process [`vectorcraft_engine::Session`] and implements the same
|
|
//! control-channel method names itself (rendering screenshots with `vectorcraft-render`), so agents
|
|
//! can draw and look at the result without a window.
|
|
//!
|
|
//! Entry points: [`Server::serve`] (stdio loop) and [`Server::handle_line`] (one message).
|
|
#![forbid(unsafe_code)]
|
|
|
|
mod backend;
|
|
mod headless;
|
|
pub mod logging;
|
|
mod prompts;
|
|
mod resources;
|
|
mod server;
|
|
mod tools;
|
|
|
|
pub use backend::{Backend, Remote};
|
|
pub use headless::Headless;
|
|
pub use prompts::{PROMPTS, PromptArg, PromptDef};
|
|
pub use resources::{DOC_JSON_URI, DOC_URI, TEMPLATES};
|
|
pub use server::{PROTOCOL_VERSION, Server};
|
|
pub use tools::{ToolResult, call_tool, tool_definitions};
|
|
|
|
/// Default control-channel address of the desktop app.
|
|
pub const DEFAULT_ADDR: &str = "127.0.0.1:7979";
|
|
|
|
#[cfg(test)]
|
|
mod tests;
|
|
#[cfg(test)]
|
|
mod tests_distortkeys;
|
|
#[cfg(test)]
|
|
mod tests_exportas;
|
|
#[cfg(test)]
|
|
mod tests_fileio;
|
|
#[cfg(test)]
|
|
mod tests_freeform;
|
|
#[cfg(test)]
|
|
mod tests_gradient;
|
|
#[cfg(test)]
|
|
mod tests_links;
|
|
#[cfg(test)]
|
|
mod tests_liquify;
|
|
#[cfg(test)]
|
|
mod tests_persp;
|
|
#[cfg(test)]
|
|
mod tests_place;
|
|
#[cfg(test)]
|
|
mod tests_protocol;
|
|
#[cfg(test)]
|
|
mod tests_svg;
|