Skip to content

spt-mcp-client

MCP (Model Context Protocol) server exposing SmartBrain operations as tools for AI assistants

Overview

spt-mcp-client implements a JSON-RPC 2.0 MCP server that exposes SmartBrain cognitive operations as callable tools for Claude and other AI assistants. It provides the protocol layer only --- the McpToolHandler trait must be implemented by a platform bridge to connect to actual SmartBrain operations. Communication uses stdio with line-delimited JSON-RPC.

Key Features

  • JSON-RPC 2.0 Protocol --- standard MCP request/response over stdio
  • Tool Discovery --- list_tools endpoint with schema definitions for each tool
  • Pluggable Handler --- McpToolHandler trait for platform-specific tool implementations
  • SmartBrain Tool Definitions --- pre-defined tool schemas for cognitive operations
  • Async Runtime --- tokio-based async stdio transport

Dependencies

Key external dependencies:

  • tokio --- async runtime for stdio transport
  • serde / serde_json --- JSON-RPC serialization

No internal SPT crate dependencies (protocol layer only).

Usage

rust
use std::sync::Arc;
use spt_mcp_client::server::{McpToolHandler, run_stdio};
use spt_mcp_client::types::{ToolCallResult, ToolDefinition};

struct MyHandler;

impl McpToolHandler for MyHandler {
    fn handle_tool_call(&self, name: &str, params: serde_json::Value)
        -> spt_mcp_client::McpResult<ToolCallResult> {
        Ok(ToolCallResult::text("result"))
    }
    fn list_tools(&self) -> Vec<ToolDefinition> {
        spt_mcp_client::tools::smartbrain_tools()
    }
}

API Reference

Core Types

TypeDescription
McpServerJSON-RPC server managing request dispatch
McpRequestIncoming JSON-RPC request
McpResponseOutgoing JSON-RPC response
ToolDefinitionSchema definition for a callable tool
ToolCallResultResult of a tool invocation
ContentBlockText or data block in a tool result
McpErrorCrate error type

Key Traits

TraitDescription
McpToolHandlerImplement to handle tool calls and list available tools

Key Functions

FunctionDescription
run_stdio()Start the MCP server on stdin/stdout
smartbrain_tools()Returns pre-defined SmartBrain tool definitions

Released under the MIT License.