Skip to main content

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.
RoutedGetTool
Multi-workspace get: supports a qualified id (<ws>:<doc>) or an explicit workspace selector, with conflict detection (R38–R43).
RoutedSearchTool
Multi-workspace search: resolves the workspace selector and groups results.
RoutedSourcesTool
Multi-workspace sources: connector status for one workspace, grouped and redacted (R44/R48/R49).
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).
WorkspacesTool
Multi-workspace discovery tool: lists registered workspaces, their health, and which is the default — without exposing any secret config values (R46–R49).

Traits§

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

Functions§

error_entry 🔒
Build one errors[] entry for a failed workspace (R37): { workspace, code, message }.
schema_with_workspace_selector 🔒
Add the optional workspace selector to a compat schema’s properties.
search_all 🔒
Fan out a search across every enabled workspace (R32–R37): concurrent, per-workspace deadline, per-workspace limit, grouped results, and one errors[] entry per failed/timed-out workspace.
search_group 🔒
Build one { workspace, items } group, tagging every item with workspace and a qualified_id (R29/R30/R36).
shape_grouped_search 🔒
A single-workspace grouped response: one group, no errors (R29/R30).
sources_group 🔒
Build one { workspace, sources } group for the sources tool.