brk_mcp
Model Context Protocol bridge enabling LLM access to Bitcoin Research Kit data.
Overview
This crate provides a Model Context Protocol (MCP) server implementation that exposes Bitcoin blockchain analytics as tools for Large Language Models. Built on the brk_rmcp library, it creates a standards-compliant bridge allowing LLMs to query Bitcoin data through structured tool calls with type-safe parameters and JSON responses.
Key Features:
- Model Context Protocol server with tools capability
- 10 specialized tools for Bitcoin data discovery and querying
- Type-safe parameter validation with structured error handling
- Stateless operation for scalability and load balancing
- Direct integration with BRK interface layer for real-time data access
- Paginated responses for large datasets (up to 1,000 entries per page)
- Multi-format output support through underlying interface layer
Target Use Cases:
- LLM-powered Bitcoin analytics and research applications
- Conversational interfaces for blockchain data exploration
- AI-driven financial analysis requiring Bitcoin metrics
- Automated research tools with natural language queries
Claude
Quick Start
Add a bitview custom connector with the following URL:
https://bitview.space/mcp
Rust
Installation
Quick Start
use MCP;
use Interface;
use ;
// Initialize with static interface reference
let interface: &'static Interface = /* your interface */;
let mcp = MCPnew;
// Use as MCP server handler
let server_info = mcp.get_info;
println!;
// Individual tool usage
let index_count = mcp.get_index_count.await?;
let vec_count = mcp.get_vec_count.await?;
let version = mcp.get_version.await?;
API Overview
Core Structure
MCP: Main server struct implementing ServerHandler trait- Tool Router: Automatic tool discovery and routing with
#[tool_router]macro - Parameters: Type-safe tool parameters with validation
- CallToolResult: Structured tool responses with success/error handling
Available Tools
Discovery Tools:
get_index_count()- Total number of available indexesget_vecid_count()- Total number of vector identifiersget_vec_count()- Total vector/index combinationsget_indexes()- List of all available indexesget_accepted_indexes()- Mapping of indexes to their variants
Data Access Tools:
get_vecids(pagination)- Paginated list of vector IDsget_index_to_vecids(index, pagination)- Vector IDs supporting specific indexget_vecid_to_indexes(id)- Indexes supported by vector IDget_vecs(params)- Main data query tool with flexible parameters
System Tools:
get_version()- Bitcoin Research Kit version information
Tool Parameters
Core Query Parameters:
index: Time dimension (height, date, week, month, etc.)ids: Dataset identifiers (comma or space separated)from/to: Range filtering (supports negative indexing from end)format: Output format (json, csv)
Pagination Parameters:
page: Page number for paginated results (up to 1,000 entries)
Examples
Basic Tool Usage
use MCP;
use ;
let mcp = MCPnew;
// Get system information
let version = mcp.get_version.await?;
println!;
// Discover available data
let indexes = mcp.get_indexes.await?;
let vec_count = mcp.get_vec_count.await?;
// Get paginated vector IDs
let pagination = PaginationParam ;
let vecids = mcp.get_vecids.await?;
Data Querying
use MCP;
use Params;
// Query latest Bitcoin price
let params = Params ;
let result = mcp.get_vecs.await?;
match result
Multi-Vector Analysis
use Params;
// Get OHLC data for last 30 days
let params = Params ;
let ohlc_data = mcp.get_vecs.await?;
Vector Discovery Workflow
use ;
// 1. Get available indexes
let indexes = mcp.get_indexes.await?;
// 2. Find vectors for specific index
let paginated_index = PaginatedIndexParam ;
let height_vectors = mcp.get_index_to_vecids.await?;
// 3. Check what indexes a vector supports
let id_param = IdParam ;
let supported_indexes = mcp.get_vecid_to_indexes.await?;
Architecture
Server Implementation
MCP Protocol Compliance:
- Implements
ServerHandlertrait for MCP compatibility - Provides
ServerInfowith tools capability enabled - Uses latest protocol version with proper initialization
- Includes instructional context for LLM understanding
Tool Registration:
#[tool_router]macro for automatic tool discovery#[tool]attribute for individual tool definitions- Structured parameter types with automatic validation
- Consistent error handling with
McpErrorresponses
HTTP Integration
Axum Router Extension:
MCPRoutestrait for router integration- Conditional MCP endpoint mounting based on configuration
- Stateless HTTP service with
LocalSessionManager - Nested service mounting at
/mcppath
Transport Layer:
StreamableHttpServicefor MCP over HTTP- Configurable server options with stateless mode
- Session management for concurrent connections
- Request context handling for proper MCP operation
Data Integration
Interface Layer Access:
- Direct access to
brk_interface::Interfacefor data queries - Static lifetime requirements for server operation
- Unified access to indexer and computer data sources
- Consistent parameter types across tool boundaries
Response Formatting:
- JSON content serialization for all tool responses
- Success/error response wrapping with proper MCP structure
- Logging integration for request tracking and debugging
- Content type handling for different response formats
Configuration
Server Information
The MCP server provides comprehensive information to LLMs:
ServerInfo
LLM Instructions
Built-in instructions explain Bitcoin data concepts:
- Vectors/vecs/arrays/datasets are interchangeable terms
- Indexes represent timeframes for data organization
- VecIds are dataset names describing their content
- Tool-based exploration before web browsing is encouraged
Code Analysis Summary
Main Structure: MCP struct implementing ServerHandler with embedded ToolRouter for automatic tool discovery
Tool Implementation: 10 specialized tools using #[tool] attribute with structured parameters and JSON responses
HTTP Integration: MCPRoutes trait extending Axum routers with conditional MCP endpoint mounting
Parameter Types: Type-safe parameter structs from brk_interface with automatic validation
Error Handling: Consistent McpError responses with proper MCP protocol compliance
Transport Layer: StreamableHttpService with stateless configuration for scalable deployment
Architecture: Standards-compliant MCP bridge providing LLM access to comprehensive Bitcoin analytics
This README was generated by Claude Code