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
HarnessToolSuitesearch_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.mdsub-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_codesBM25 + Dense Vector RRF
query_icd_knowledge_graphExcludes1, Combo, Siblings
get_child_codesAuto Billable-Leaf Drilldown
mcp__ehr__get_labsDynamic JSON-RPC MCP Tool
Option A (Recommended): Zero-Code Internal Tool via MCP
- Expose an internal JSON-RPC 2.0 MCP server (
streamable_httporsse) implementinginitialize,tools/list, andtools/call. - Open Settings → Tools & MCP (
/settings/tools_mcp) and click Connect MCP Server. - Configure auth (
none,bearer, orX-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) andHarnessToolSuite.__init__(). - Step 3: Add the OpenAI JSON tool schema in
openai_tool_schemas()and dispatch branch inHarnessToolSuite.execute(). - Step 4: Add a concise summary formatter in
_summarize_tool_call()inloop.pyso DAG tooltips display clean telemetry. - Step 5: Add unit & integration tests verifying schema presence, execution output, and
explainability_dag.tool_usage_logrecording.
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}