Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MCP Tooling

The Model Context Protocol (MCP) is an open standard for connecting AI assistants to external tools and data sources. The PAIML stack provides first-class MCP support through two complementary crates:

CrateVersionPurpose
pmcpv1.8.6Low-level Rust SDK for building MCP servers and clients
pforgev0.1.4High-level declarative framework for MCP servers

Why MCP?

MCP enables AI assistants (like Claude) to:

  • Execute tools and functions
  • Access external data sources
  • Integrate with APIs and services
  • Maintain stateful sessions
┌─────────────────┐     MCP Protocol     ┌─────────────────┐
│   AI Assistant  │ ◄─────────────────► │   MCP Server    │
│   (Claude)      │                      │   (Your Tools)  │
└─────────────────┘                      └─────────────────┘

Stack Integration

MCP tooling integrates with the broader PAIML ecosystem:

┌─────────────────────────────────────────────────────────┐
│                    MCP Server (pforge)                  │
├─────────────────────────────────────────────────────────┤
│  Tool: train_model    │  Tool: query_data               │
│  → Entrenar           │  → Trueno-DB                    │
├───────────────────────┼─────────────────────────────────┤
│  Tool: run_inference  │  Tool: visualize                │
│  → Realizar           │  → Trueno-Viz                   │
└─────────────────────────────────────────────────────────┘

Quick Start

For most use cases, pforge provides the fastest path to a working MCP server:

# Install pforge CLI
cargo install pforge-cli

# Create new server
pforge new my-ml-server
cd my-ml-server

# Run server
pforge serve

Option 2: pmcp (Low-Level)

For custom implementations or advanced use cases:

use pmcp::{Server, Tool, ToolHandler};

#[tokio::main]
async fn main() {
    let server = Server::new("my-server")
        .with_tool(MyTool::new())
        .build();

    server.serve_stdio().await.unwrap();
}

Use Cases

Use CaseRecommended Approach
Simple tool serverpforge with YAML config
Complex business logicpforge with native handlers
Custom protocol needspmcp directly
Embedded in larger apppmcp as library

Next Steps