Principle:ARCANGEL0 EVA MCP Tool Host Architecture
| Knowledge Sources | |
|---|---|
| Domains | Agentic_Systems, Tool_Integration, Architecture |
| Last Updated | 2026-10-29 14:00 GMT |
Overview
Architecture pattern for exposing heterogeneous tools — built-in functions, external CLI wrappers, and remote MCP servers — through a unified protocol with per-tool annotations, mode-gated availability, and result post-processing.
Description
The Model Context Protocol (MCP) standardizes how language models discover and invoke tools. An MCP tool host acts as the bridge between the agent loop and all available tools, regardless of their implementation:
- Built-in tools: Registered directly on an in-process MCP server (e.g., `bash`, `list_files`, `intel_upsert_asset`).
- Armory CLI tools: Red-team tools wrapped through an MCP adapter that exposes their CLI interface as callable tools.
- Custom MCP tools: User-defined external tools connected via stdio MCP clients.
The host maintains a tool registry mapping fully-qualified names (e.g., `mitsu__bash`) to their definitions, including descriptions, input schemas, read-only flags, and server origin. On each turn, it provides the agent with the mode-appropriate subset of tools.
Key design decisions:
- Unified dispatch: All tools, regardless of origin, are called through the same `call()` method.
- Result truncation: Tool output is capped (40,000 chars) to prevent context overflow.
- Post-processing: A configurable `tool_result_handler` can append Intel capture notes to any tool result.
- Connection management: External MCP clients are managed through an `AsyncExitStack` for clean startup/shutdown.
Usage
Apply this principle when:
- Building an agent that needs access to both in-process and external tools.
- Integrating external CLI tools as first-class MCP tools.
- Supporting dynamic tool availability based on operational mode.
- Needing result post-processing (Intel capture, artifact tracking) across all tool types.
Theoretical Basis
The host follows the registry + dispatcher pattern with protocol-agnostic invocation:
# Abstract algorithm (NOT real implementation)
class ToolHost:
def register(self, name, schema, handler, read_only):
self.tools[name] = {schema, handler, read_only}
def provider_tools(self, mode):
return [t for t in self.tools.values() if allowed_in_mode(t, mode)]
async def call(self, name, arguments):
tool = self.tools[name]
result = await tool.handler(**arguments)
result = truncate(result, MAX_RESULT)
result = await self.post_process(name, arguments, result)
return result, is_error, made_changes
Each tool carries `ToolAnnotations` (read_only_hint, destructive_hint, open_world_hint) that the host uses for safety classification.
Practical Guide
- Namespace tool names by server (e.g., `mitsu__bash`, `armory__nmap`) to avoid collisions.
- Use `AsyncExitStack` to manage external MCP client lifecycles.
- Cap result size uniformly across all tool types.
- Apply post-processing hooks for Intel capture and artifact tracking at the host level, not per-tool.
- Expose `provider_tools(mode)` that filters by operational mode so the agent only sees relevant tools.