techne 0.1.0-dev.2

A simple MCP implementation for Rust
Documentation

Techne

Documentation Crates.io License Downloads Test Status

An MCP implementation for Rust focused on simplicity and type-safety.

Features

  • Completely handmade!
  • No macros!
  • Coherent schemas enforced at the type level
  • Stdio and Streamable HTTP transports
  • Custom transports
  • Latest protocol version (2025-06-18)

Very experimental! Only the tools capability is currently supported.

Server

Create a Server, choose your desired transport, list your tools, and run:

use techne::Server;
use techne::server::Stdio;
use techne::server::tool::{tool, string};

use std::io;

#[tokio::main]
pub async fn main() -> io::Result<()> {
    let server = Server::new("techne-server-example", env!("CARGO_PKG_VERSION"));
    let transport = Stdio::current();

    let tools = [
        tool(say_hello, string("name", "The name to say hello to"))
            .name("say_hello")
            .description("Say hello to someone"),
    ];

    server.tools(tools).run(transport).await
}

async fn say_hello(name: String) -> String {
    format!("Hello, {name}!")
}

Client

Create a Client with your desired transport and query the server:

use techne::Client;
use techne::client::Stdio;
use techne::mcp::json;

use std::io;

#[tokio::main]
pub async fn main() -> io::Result<()> {
    let transport = Stdio::run("cargo", ["run", "--example", "server"])?;

    let mut client = Client::new(
        "techne-client-example",
        env!("CARGO_PKG_VERSION"),
        transport,
    )
    .await?;

    let tools = client.list_tools().await?;

    let hello = client
        .call_tool("say_hello", json!({ "name": "World" }))
        .await?;

    dbg!(tools);
    dbg!(hello);

    Ok(())
}