Skip to main content

Crate nachalnik_mcp

Crate nachalnik_mcp 

Source
Expand description

An MCP bridge for nachalnik: a tool somebody else wrote, as a Tool like any other.

use nachalnik::{Config, Kernel};
use nachalnik_mcp::Server;
use tokio::process::Command;

let kernel = Kernel::new(Config::default());

let files = Server::spawn("files", Command::new("mcp-server-filesystem")).await?;
let installed = files.install(&kernel).await?;
println!("{} tools: {}", installed.added.len(), installed.added.join(", "));

§why this is not in the runtime

nachalnik promises to spawn no processes, open no sockets and run nothing in the background, and speaking MCP needs all three. MCP also revises faster than a context library’s version should, so the runtime is not tied to it.

It needs nothing the runtime does not already expose. An MCP tool is a Tool that forwards to a server. Tools arriving and leaving use Kernel::add_tool and remove_tool, which put them on the event stream. A stop is read off the tool’s OutputSink before a call goes out and while the server has it, and the server is then sent MCP’s cancellation. A structured result is Content::Json. A server’s progress notifications are not forwarded yet: rmcp puts a progress token on every request, and what a server sends against it is dropped.

§what it decides, and what it refuses to

These are judgement calls with defaults here, and yours to change rather than the kernel’s:

  • What a tool is allowed to do. MCP tools carry hints. The specification says a client should never make tool-use decisions based on hints from an untrusted server. Trust defaults to believing none of them; read its documentation before changing that.
  • What a tool is called. Two servers may both offer read, and a kernel holds one tool per identifier, so names are prefixed with the server’s unless Server::without_prefix says otherwise. Nothing is ever replaced quietly: Installed::replaced says what was displaced.

Re-exports§

pub use rmcp;

Structs§

Installed
What installing a server’s tools into a kernel did.
Server
A connection to one MCP server.

Enums§

Error
Something an MCP server did, or failed to do.
Trust
How the capabilities of a server’s tools are decided.

Constants§

LARGEST_IMAGE
The largest image carried into the context, in base64.

Type Aliases§

Result
The result of talking to an MCP server.