HTS MCP
Skip to Content
ArchitectureOverview

Architecture

HTS MCP is a monolithic Python application with three interface adapters sharing a common core.

System Overview

┌──────────────────────────────────────────────────────────┐ │ Interface Layer │ │ │ │ ┌──────────────┐ ┌──────────────┐ ┌────────────────┐ │ │ │ MCP Server │ │ REST API │ │ CLI (Click) │ │ │ │ (FastMCP) │ │ (FastAPI) │ │ │ │ │ └──────┬───────┘ └──────┬───────┘ └───────┬────────┘ │ │ │ │ │ │ │ └─────────────────┼──────────────────┘ │ │ │ │ ├───────────────────────────┼──────────────────────────────┤ │ Core Layer │ │ │ │ │ ┌────────────┐ ┌────────┴───────┐ ┌────────────────┐ │ │ │ Search │ │ Enrichment │ │ Graph │ │ │ │ Engine │ │ Pipeline │ │ Pipeline │ │ │ └──────┬─────┘ └───────┬────────┘ └──────┬─────────┘ │ │ │ │ │ │ │ ┌──────┴────────────────┴──────────────────┴─────────┐ │ │ │ Database Layer (psycopg2) │ │ │ │ Connection Pool (2-10) │ │ │ └────────────────────────┬───────────────────────────┘ │ │ │ │ ├───────────────────────────┼──────────────────────────────┤ │ External Services │ │ │ │ │ ┌────────────────────────┼───────────────────────────┐ │ │ │ PostgreSQL │ OpenAI API │ │ │ │ + pgvector │ (embeddings + LLM) │ │ │ └────────────────────────┴───────────────────────────┘ │ └──────────────────────────────────────────────────────────┘

Interface Adapters

All three adapters call the same underlying core functions:

AdapterProtocolFrameworkEntry Point
MCPstdio (Model Context Protocol)FastMCPsrc/hts/mcp/server.py
RESTHTTP/JSONFastAPIsrc/hts/api/
CLITerminalClicksrc/hts/cli/__main__.py

Core Components

ComponentPurposeKey Files
Search EngineHybrid semantic/lexical searchcore/search/engine.py
Enrichment PipelineAI descriptions and embeddingscore/enrichment/
Semantic GraphRelationship classificationcore/graph/
DatabasePostgreSQL with pgvectorcore/db/

Data Flow

Query Path (Read)

User Query → Interface Adapter → Search Engine → pgvector → Results

Pipeline Path (Write)

Source Data → Loader → Bronze Table → Enricher → Embeddings → KNN → Classifier → Graph

Technology Stack

LayerTechnology
LanguagePython 3.11+
Package manageruv
MCP frameworkFastMCP
REST frameworkFastAPI + Uvicorn
CLI frameworkClick
DatabasePostgreSQL + pgvector
EmbeddingsOpenAI text-embedding-3-small (1536D)
LLMGPT-5.4 Nano (enrichment + classification)
HostingSupabase (PostgreSQL), any Python host (MCP/API/CLI)