|
|
||
|---|---|---|
| .vscode | ||
| deploy/systemd | ||
| docs | ||
| migrations | ||
| scripts | ||
| src/techlib_mcpserver | ||
| tests | ||
| .env.example | ||
| .env.test.example | ||
| .gitignore | ||
| AGENTS.md | ||
| README.md | ||
| alembic.ini | ||
| ingest-client.env.example | ||
| pyproject.toml | ||
| release.manifest.yml | ||
README.md
TechDoc Library MCP Server v1
TechDoc Library MCP Server is a Linux-oriented MCP service for managing a technical document library. It ingests original document files plus metainfo, stores versioned state in PostgreSQL, runs optional provider-driven extraction and enrichment on the server, and exposes version-aware retrieval through an MCP facade.
Architecture
The service is organized into four cooperating layers:
MCP Facade- the external tool surface and request/response adapterProcessing Orchestrator- workflow coordination for ingest, delete, reindex, and provider branchesDocument Library Engine- authoritative persistence, versioning, search, and retrieval logicProvider Layer- optional external adapters for extraction and metadata enrichment
The runtime flow is:
- MCP requests enter the facade.
- The facade validates payloads and routes them to orchestrator or engine services.
- The orchestrator coordinates optional provider branches and operational workflows.
- The engine persists documents, versions, metadata, searchable text, and audit events.
- Retrieval returns version-aware document snapshots and search hits.
Local development can use a Python virtual environment, and production deployment also runs the service from a dedicated virtual environment under the techlib service account via systemd.
Repository Structure
src/techlib_mcpserver/app/- application bootstrap, config, and loggingsrc/techlib_mcpserver/mcp_facade/- MCP schemas and routingsrc/techlib_mcpserver/orchestrator/- ingest, delete, extraction, enrichment, and reindex workflowssrc/techlib_mcpserver/engine/- document persistence, versioning, metadata, search, and retrieval servicessrc/techlib_mcpserver/providers/- provider contracts, registry, and HTTP adapterssrc/techlib_mcpserver/persistence/- SQLAlchemy models, repositories, and DB helperssrc/techlib_mcpserver/search/- indexing and embedding abstractionssrc/techlib_mcpserver/files/- object storage abstraction for original filessrc/techlib_mcpserver/contracts/- shared domain vocabularysrc/techlib_mcpserver/utils/- shared utilities, including release packaging helpers
Core Components
appwires configuration, bootstrap, and the FastAPI runtime.mcp_facadetranslates MCP requests into internal service calls and shapes responses.orchestratorowns workflow policy and optional provider execution.engineis the only persistence boundary that writes library state. Ingest stores the original file bytes first, then providers refresh searchable state.providersstay opaque to the core system and never write directly to the library database.persistenceexposes the PostgreSQL schema and repository layer.searchprovides the searchable representation and retrieval seams.filesowns storage of original document bytes.
Document Metainfo
Ingest requests use metadata.subjects as the structured subject description for a document.
Keep document_type_name separate from subject data.
A subject item captures the equipment context for the document and can include:
vendor_nameequipment_typemodelmodel_familysubject_payloadfor opaque extensions
The engine denormalizes the main subject fields for search and catalog queries while keeping the full subject payload available for future expansion.
Server-Side Text Extraction
The built-in extraction provider runs on the server during ingest and materializes a structured content section for the document representation.
That content payload carries:
native_textfor direct text extractionocr_textfor OCR fallbackmerged_textas the canonical searchable textlanguage_hintforru,en,mixed, orunknownconfidenceandpages[]for provenance and debugging
The provider uses a strategy chain:
- direct extraction for PDF, DOCX, TXT, and similar formats
- OCR fallback for scanned PDFs and image files when OCR support is available
The core engine persists the provider payload as opaque data and refreshes searchable representation after each successful extraction step.
Integrations
The project integrates with:
- FastAPI for the runtime service
- SQLAlchemy 2.x and Alembic for PostgreSQL persistence and migrations
- psycopg for PostgreSQL connectivity
- Pydantic v2 and pydantic-settings for config and facade models
- optional HTTP-based extraction and enrichment providers
- systemd for Linux deployment
Documentation Map
The repository is intentionally compact, but the architecture and operational boundaries are already in place for the full v1 flow.