Module traits

Module traits 

Source
Expand description

Extension traits for custom connectors and tools.

This module provides the trait-based extension system for Context Harness. Users can implement Connector and Tool in Rust to create compiled extensions that run alongside built-in and Lua-scripted ones.

§Architecture

┌──────────────────────────────────────────┐
│           ConnectorRegistry              │
│  ┌─────────┐ ┌─────────┐ ┌────────────┐ │
│  │Built-in │ │  Lua    │ │  Custom    │ │
│  │FS/Git/S3│ │ Script  │ │ (Rust)     │ │
│  └─────────┘ └─────────┘ └────────────┘ │
└──────────────┬───────────────────────────┘
               ▼
         run_sync() → ingest pipeline
┌──────────────────────────────────────────┐
│              ToolRegistry                │
│  ┌─────────┐ ┌─────────┐ ┌────────────┐ │
│  │Built-in │ │  Lua    │ │  Custom    │ │
│  │search   │ │ Script  │ │ (Rust)     │ │
│  │get/src  │ │ Tools   │ │  Tools     │ │
│  └─────────┘ └─────────┘ └────────────┘ │
└──────────────┬───────────────────────────┘
               ▼
         run_server() → MCP HTTP API

§Usage

use context_harness::traits::{ConnectorRegistry, ToolRegistry};

let mut connectors = ConnectorRegistry::new();
// connectors.register(Box::new(MyConnector::new()));

let mut tools = ToolRegistry::new();
// tools.register(Box::new(MyTool::new()));

See docs/RUST_TRAITS.md for the full specification and examples.

Structs§

ConnectorRegistry
Registry for connectors (built-in and custom).
GetTool
Built-in document retrieval tool. Delegates to get_document.
SearchOptions
Options for ToolContext::search.
SearchTool
Built-in search tool. Delegates to ToolContext::search.
SourcesTool
Built-in sources listing tool. Delegates to get_sources.
ToolContext
Context bridge for tool execution.
ToolRegistry
Registry for tools (built-in, Lua, and custom Rust).

Traits§

Connector
A data source connector that produces documents for ingestion.
Tool
A custom MCP tool that agents can discover and call.