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§
- Connector
Registry - Registry for connectors (built-in and custom).
- GetTool
- Built-in document retrieval tool. Delegates to
get_document. - Routed
GetTool - Multi-workspace
get: supports a qualified id (<ws>:<doc>) or an explicitworkspaceselector, with conflict detection (R38–R43). - Routed
Search Tool - Multi-workspace
search: resolves theworkspaceselector and groups results. - Routed
Sources Tool - Multi-workspace
sources: connector status for one workspace, grouped and redacted (R44/R48/R49). - Search
Options - Options for
ToolContext::search. - Search
Tool - Built-in search tool. Delegates to
ToolContext::search. - Sources
Tool - Built-in sources listing tool. Delegates to
get_sources. - Tool
Context - Context bridge for tool execution.
- Tool
Registry - Registry for tools (built-in, Lua, and custom Rust).
- Workspaces
Tool - 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
workspaceselector to a compat schema’sproperties. - search_
all 🔒 - Fan out a
searchacross every enabled workspace (R32–R37): concurrent, per-workspace deadline, per-workspacelimit, grouped results, and oneerrors[]entry per failed/timed-out workspace. - search_
group 🔒 - Build one
{ workspace, items }group, tagging every item withworkspaceand aqualified_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 thesourcestool.