Expand description
ubl-mcp — Secure Model Context Protocol for LogLine Agents
MCP tools, but with a kernel: policy-first, audit-ready, and boringly predictable.
This crate is a clean implementation of the Model Context Protocol (JSON-RPC 2.0) that routes every tool call through a policy gate. It’s the “universal IO bus” for your agents — interop with the MCP ecosystem without giving the model a foot-gun.
§Security Model
┌─────────────┐ ┌──────────────┐ ┌──────────────┐ ┌─────────────┐
│ Agent Brain ├────▶│ PolicyGate ├────▶│ Transport ├────▶│ MCP Server │
└─────────────┘ │ (permit/deny)│ │ (stdio/http) │ └──────┬──────┘
└──────────────┘ └──────────────┘ │
│ │
▼ ▼
┌──────────────┐ ┌─────────────┐
│ AuditSink │ │ Tool Result │
│ (UBL Ledger) │ └─────────────┘
└──────────────┘- Gate-before-IO: tool calls are proposals → Gate decides Permit/Deny/Challenge
- Auditable: every call (success, failure, or blocked) is recorded
- Schema-first: tools declare their input schema (via schemars)
§Example
use ubl_mcp::{McpClient, ToolResult, gate::AllowAll, audit::NoAudit, client::MockEndpoint};
let client = McpClient::new(AllowAll, NoAudit, MockEndpoint::with_text("hello"));
let result = client
.tool("echo", serde_json::json!({"text": "hello"}))
.execute()
.await?;
println!("Result: {:?}", result);§Features
client(default): MCP client with SecureToolCallserver(default): MCP server with schema-first tool registrationtransport-stdio(default): stdio transport (line-delimited JSON)transport-http: HTTP transport (optional)gate-tdln: TDLN Gate integration (optional)audit: UBL Ledger audit sink (optional)
Re-exports§
pub use client::McpClient;clientpub use client::MockEndpoint;clientpub use client::RpcEndpoint;clientpub use client::SecureToolCall;clientpub use server::McpServer;serverpub use server::ServerBuilder;server
Modules§
- audit
- Audit sink for recording tool calls.
- client
client - MCP Client with Gate enforcement and Audit logging.
- gate
- Policy gate for tool call authorization.
- server
server - MCP Server with schema-first tool registration.
- transport
transport-stdio - Transport implementations for MCP.
Structs§
- Json
RpcError - JSON-RPC 2.0 error object.
- Json
RpcNotification - JSON-RPC 2.0 notification (no ID, no response expected).
- Json
RpcRequest - JSON-RPC 2.0 request.
- Json
RpcResponse - JSON-RPC 2.0 response.
- Tool
Definition - MCP tool definition.
- Tool
Result - MCP tool execution result.
Enums§
- Content
Block - Content block in a tool result.
- McpError
- MCP errors specific to this crate.
- Request
Id - JSON-RPC 2.0 request/response ID.