Sparsi allows you to build high-performance MCP servers that speak the Model Context Protocol natively. By wrapping complex business processes as compiled workflows, you get tools that are faster, more reliable, and cheaper to run than standard "prompt-only" MCP implementations.
Pick by how much server-side state your workflow needs across calls.
Set transport on the vertex to "stdio" (default) for local
subprocesses or "http" for a remote MCP server. The other params follow.
params := map[string]string{
"transport": "stdio",
"command": "npx",
"args": "-y,@playwright/mcp@latest",
"tool_name": "browser_navigate",
"init_timeout_ms": "120000",
"call_timeout_ms": "90000",
}
params := map[string]string{
"transport": "http",
"url": "https://docs.mcp.cloudflare.com/mcp",
"tool_name": "search_cloudflare_documentation",
"init_timeout_ms": "30000",
"call_timeout_ms": "60000",
// optional auth header(s):
// "headers": "Authorization=Bearer ${TOKEN}",
}
Set pool_size on stdio vertices to maintain a target number of pre-started
MCP subprocesses. Vertices that share the same canonical session spec (command, args, env,
init_timeout) share warm slots — fan-out runs see no cold-start in steady state.
pool_sizeTarget capacity per spec. 0 (default) disables pooling — each
Run opens and closes its own session.
pool_prewarmtrue (default) fills the pool during Setup so the first
Run already has warm sessions. Set false for lazy fill on
first use.
ShutdownMCPPoolCall library.ShutdownMCPPool(ctx) from main() (typically
via defer) so pre-started subprocesses drain cleanly at exit.
Each borrow is a fresh session — the pool never reuses a session for a second logical call.
Pooling is supported only for transport="stdio" in v1.
Two interfaces let you decouple your operator's In and Out
types from the tool's exact JSON. Implement on the pointer receiver.
// Rewrite the args object before it goes on the wire.
func (in *MyInput) FormatMCPArgs() (any, error) {
return map[string]any{
"q": in.Query,
"top": in.Limit,
}, nil
}
// Parse the tool's text + structured payload yourself.
func (out *MyOutput) ParseMCPResponse(text string, structured json.RawMessage) error {
if len(structured) > 0 {
return json.Unmarshal(structured, out)
}
out.Text = text
return nil
}
Tool-level errors (servers that return IsError=true) surface as
*library.MCPToolError with the tool name and the server's text. Use
errors.As from inside an MCPScriptOp Script to recover from
anticipated failures (element-not-found, page-not-loaded, etc.) without aborting the run.
MCPScriptOp drives one playwright session to scrape Google, then
MapOver spawns N parallel sessions to screenshot each URL. Pool size 8;
warm-replenish.
MCPCallOp against the public Cloudflare docs MCP server over streamable
HTTP. No subprocess, no API keys.