Architecture & API6 min read

Harness Tools, Zero-Code MCP & Adding Custom Tools

Built-in coding harness tools, connecting internal company MCP servers zero-code, and the 5-step engineering guide to adding native tools.

Registered Built-In + Dynamic Tools

HarnessToolSuite
  • search_icd_codes — Hybrid BM25 + Dense Vector + RRF across ~98k ICD-10-CM codes (Stages 3 & 4).
  • query_icd_knowledge_graph — Graph traversal for parents, siblings, Excludes1/2, Code First, Use Additional, and combo targets.
  • get_child_codes — Recursive billable-leaf drilldown for non-billable headers.
  • validate_icd_codes — Zero-LLM CMS tabular compliance & MCE hard gate.
  • read_skill — On-demand loading of specialty .md sub-guides with SHA-256 stamping.
  • web_search_policy — Off by default (air-gap safe); PHI-scrubbed allowlisted CMS/CDC lookup.
  • mcp__<server>__<tool> — Dynamically discovered internal EHR, lab, formulary, or payer LCD/NCD tools.
HarnessToolSuite · Built-In + Auto-Discovered MCP Tools
search_icd_codes
BM25 + Dense Vector RRF
query_icd_knowledge_graph
Excludes1, Combo, Siblings
get_child_codes
Auto Billable-Leaf Drilldown
mcp__ehr__get_labs
Dynamic JSON-RPC MCP Tool

Option A (Recommended): Zero-Code Internal Tool via MCP

  • Expose an internal JSON-RPC 2.0 MCP server (streamable_http or sse) implementing initialize, tools/list, and tools/call.
  • Open Settings → Tools & MCP (/settings/tools_mcp) and click Connect MCP Server.
  • Configure auth (none, bearer, or X-API-Key) and toggle Scrub PHI from MCP tool arguments as needed.
  • Click Discover Tools — every tool registers instantly as mcp__<server>__<tool> and logs to the Explainability DAG.

Option B (Core Engineering): 5-Step Native Built-In Tool Guide

  • Step 1: Implement a deterministic async-friendly service module under src/atreyamd/tools/<tool>.py.
  • Step 2: Inject into AppContainer (src/atreyamd/api/deps.py) and HarnessToolSuite.__init__().
  • Step 3: Add the OpenAI JSON tool schema in openai_tool_schemas() and dispatch branch in HarnessToolSuite.execute().
  • Step 4: Add a concise summary formatter in _summarize_tool_call() in loop.py so DAG tooltips display clean telemetry.
  • Step 5: Add unit & integration tests verifying schema presence, execution output, and explainability_dag.tool_usage_log recording.
Example Native Tool Module (src/atreyamd/tools/hcc_calculator.py)
python
from __future__ import annotations
from typing import Any

class HCCRiskTool:
    """Computes CMS-HCC V28 categories and RAF capture for candidate ICD codes."""

    def evaluate(self, codes: list[str]) -> dict[str, Any]:
        # Deterministic lookup — zero network calls, zero PHI required
        mapped = {c.upper(): self._lookup_hcc(c.upper()) for c in codes}
        return {"codes_checked": len(codes), "hcc_mappings": mapped}