Go to file
Ilgiz Kalmetyev fa457f9da8 расширено руководство по развёртыванию 2026-03-15 13:56:31 +05:00
downloads chore: cleanup git artifacts and remove probes 2026-03-15 13:44:24 +05:00
examples расширено руководство по развёртыванию 2026-03-15 13:56:31 +05:00
library chore: cleanup git artifacts and remove probes 2026-03-15 13:44:24 +05:00
plan bootstrap 2026-03-15 12:46:36 +05:00
src/manuals_mcp chore: cleanup git artifacts and remove probes 2026-03-15 13:44:24 +05:00
tests chore: cleanup git artifacts and remove probes 2026-03-15 13:44:24 +05:00
.gitignore chore: cleanup git artifacts and remove probes 2026-03-15 13:44:24 +05:00
AGENTS.md bootstrap 2026-03-15 12:46:36 +05:00
README.md bootstrap 2026-03-15 12:46:36 +05:00
pyproject.toml bootstrap 2026-03-15 12:46:36 +05:00
status.md bootstrap 2026-03-15 12:46:36 +05:00

README.md

manufacturer-manuals-mcp

Production-oriented MCP service for manufacturer manual discovery and local manual library management.

Operating modes

  • MCP service mode (for agents):
    • agents call MCP tools/resources exposed by ManualsMCPApplication.
    • RBAC is enforced by role/token (read, write, admin).
  • Operator utility mode (manual operations via Python/CLI-style scripts):
    • operator runs scripted/manual tool calls through Python (app.call_tool(...)).
    • suitable for terminal-driven workflows and automation jobs.
  • Operator WebUI mode (browser):
    • FastAPI + Jinja UI over the same ManualsMCPApplication object and tool set.
    • routes under /ui/*, cookie-token auth, role-based action gating.

Features

  • Search by product_code, model_name, or free-form query.
  • Offline-first search behavior for find_product_manuals: local library + local content index only.
  • Legacy external-search inputs (search_scope, allow_unofficial_fallback, max_external_candidates) are compatibility-only.
  • Strict version policy: default latest_non_obsolete.
  • Obsolete versions are returned only with explicit request.
  • Manual ingestion supports exactly one source:
    • local file (file_path)
    • direct URL download (download_url)
  • URL ingest source policy:
    • official/portal URL allowed by default
    • unofficial URL requires allow_unofficial_url=true
  • Async ingestion pipeline with task tracking.
  • RBAC-style permissions (read, write, admin).

Project structure

Implemented under src/manuals_mcp/:

  • models/, normalization/, search/, extraction/
  • library/ (repository, ingestion, indexing, versioning, checksums)
  • policy/, security/, observability/
  • tools/, resources/, server.py, config.py

Data layout

Library data:

  • library/vendors/... for documents and metadata
  • library/index.json for catalog summary
  • library/manuals.db for SQLite tables + FTS
  • library/indexes/hnsw_chunks.bin + hnsw_labels.json for ANN sidecar
  • library/downloads/... for URL-ingested source files

Main tools

  • find_product_manuals
  • find_manual_versions
  • get_manual_by_version
  • ingest_manual_document (supports file_path OR download_url)
  • get_ingestion_task_status
  • list_library_documents
  • set_latest_manual_version
  • mark_manual_obsolete
  • reindex_library_content

MCP service profile

  • Primary entrypoint: manuals_mcp.server.create_app.
  • Tool execution API: app.call_tool(tool_name, args, ctx=ToolContext(token=...)).
  • Resource API: app.read_resource(resource_uri).
  • Queue worker API: app.process_ingestion_queue().
  • Search behavior:
    • local-only for find_product_manuals (offline mode).
    • legacy external-search inputs remain accepted for compatibility and are ignored with warning.

Resources

  • resource://vendors/catalog
  • resource://vendors/{vendor}/domains
  • resource://library/catalog
  • resource://library/{vendor}/{model}
  • resource://library/{vendor}/{model}/{doc_type}
  • resource://library/index/stats

Install

python -m venv .venv
. .venv/Scripts/activate
pip install -e .[test]

Optional embedding stack:

pip install -e .[embeddings]

Run

Local app bootstrap

python -c "from manuals_mcp.server import create_app; app = create_app(); print('ready')"

Run WebUI/API process

python -m manuals_mcp.server_api

Open http://127.0.0.1:8080/ui/login (or values from env MANUALS_MCP_WEB_HOST/MANUALS_MCP_WEB_PORT).

Minimal local worker for async ingestion queue

from manuals_mcp.server import create_app

app = create_app()
processed = app.process_ingestion_queue()
print(f"processed tasks: {processed}")

Run worker entrypoint (systemd/timer friendly)

python -m manuals_mcp.worker

Usage

read tools can be called without token context.
write/admin tools require ToolContext(token=...) with mapped role in AuthConfig.

1. Search manuals (offline behavior)

from manuals_mcp.server import create_app

app = create_app()
result = app.call_tool(
    "find_product_manuals",
    {
        "query": "C9300 installation guide",
        "version_policy": "latest_non_obsolete",
        "search_scope": "hybrid",  # compatibility input, external lookup is disabled
        "allow_unofficial_fallback": True,  # compatibility input, ignored in offline mode
        "max_external_candidates": 10,  # compatibility input, ignored in offline mode
        "max_results": 5,
    },
)
print(result["warnings"])

Operator utility workflow (terminal/script)

from manuals_mcp.config import AuthConfig, ManualsMCPConfig
from manuals_mcp.server import ToolContext, create_app

cfg = ManualsMCPConfig(
    auth=AuthConfig(token_roles={"writer-token": "write", "admin-token": "admin"})
)
app = create_app(cfg)
writer_ctx = ToolContext(token="writer-token")

# 1) find manuals in local library (offline search)
print(
    app.call_tool(
        "find_product_manuals",
        {"query": "C9300 installation guide", "version_policy": "latest_non_obsolete"},
    )
)

# 2) enqueue ingestion from local file or exact URL
accepted = app.call_tool(
    "ingest_manual_document",
    {
        "vendor": "Cisco",
        "model": "Catalyst 9300",
        "product_code": "C9300-48P",
        "title": "Catalyst 9300 Installation Guide",
        "doc_type": "installation_guide",
        "source_type": "manual_upload_verified",
        "file_path": "examples/sample_manual.txt",
    },
    ctx=writer_ctx,
)

# 3) process queue and inspect status
app.process_ingestion_queue()
print(app.call_tool("get_ingestion_task_status", {"task_id": accepted["task_id"]}, ctx=writer_ctx))

WebUI routes (v1)

  • GET /health/live - liveness probe
  • GET /ui/login, POST /ui/login, POST /ui/logout
  • GET /ui/library - browse + filters
  • GET /ui/search - offline manual search (warnings shown in UI)
  • GET /ui/versions - known versions for query/device
  • GET /ui/ingest, POST /ui/ingest - ingest by server-side file_path or exact download_url
  • GET /ui/tasks/{task_id} - ingestion status
  • POST /ui/version/set-latest - admin action
  • POST /ui/version/mark-obsolete - admin action

WebUI role model

  • read: library/search/versions pages
  • write: ingest page/actions + task status
  • admin: all above + version state actions (set-latest, mark-obsolete, reindex via API/tool)

2. Ingest manual document from local file

from pathlib import Path
from manuals_mcp.config import AuthConfig, ManualsMCPConfig
from manuals_mcp.server import ToolContext, create_app

cfg = ManualsMCPConfig(auth=AuthConfig(token_roles={"writer-token": "write"}))
app = create_app(cfg)
writer_ctx = ToolContext(token="writer-token")

Path("examples/sample_manual.txt").write_text("C9300 installation guide version 17.9", encoding="utf-8")

accepted = app.call_tool(
    "ingest_manual_document",
    {
        "vendor": "Cisco",
        "model": "Catalyst 9300",
        "product_code": "C9300-48P",
        "title": "Catalyst 9300 Installation Guide",
        "doc_type": "installation_guide",
        "version": "17.9",
        "language": "en",
        "publication_date": "2025-01-20",
        "source_type": "manual_upload_verified",
        "file_path": "examples/sample_manual.txt",
        "mark_as_latest": True,
        "official": True,
    },
    ctx=writer_ctx,
)
print(accepted)

3. Ingest manual document by exact URL

accepted = app.call_tool(
    "ingest_manual_document",
    {
        "vendor": "Cisco",
        "model": "Catalyst 9300",
        "product_code": "C9300-48P",
        "title": "Catalyst 9300 Installation Guide",
        "doc_type": "installation_guide",
        "version": "17.9",
        "language": "en",
        "publication_date": "2025-01-20",
        "download_url": "https://www.cisco.com/support/manuals/c9300-installation-guide.pdf",
        "allow_unofficial_url": False,
        "mark_as_latest": True,
    },
    ctx=writer_ctx,
)
print(accepted)

4. Check ingestion task status

status = app.call_tool(
    "get_ingestion_task_status",
    {"task_id": accepted["task_id"]},
    ctx=writer_ctx,
)
print(status)

5. Token/RBAC call

from manuals_mcp.config import AuthConfig, ManualsMCPConfig
from manuals_mcp.server import ToolContext, create_app

cfg = ManualsMCPConfig(
    auth=AuthConfig(token_roles={"admin-token": "admin", "writer-token": "write"})
)
app = create_app(cfg)

admin_ctx = ToolContext(token="admin-token")
app.call_tool("reindex_library_content", {"vendor": "Cisco"}, ctx=admin_ctx)

Linux deployment examples

See:

  • examples/deploy/linux/manuals-mcp.env.example
  • examples/deploy/linux/manuals-mcp-api.service
  • examples/deploy/linux/manuals-mcp-worker.service
  • examples/deploy/linux/manuals-mcp-worker.timer
  • examples/deploy/linux/nginx/manuals-mcp.conf
  • examples/deploy/linux/DEPLOYMENT.md

The sample units are for operator-managed Linux environments (systemd + nginx + env).

Tests

pytest

Notes

  • Embedding backend defaults to intfloat/multilingual-e5-small.
  • If embedding dependencies are missing, deterministic hash embeddings are used as fallback.
  • OCR for scanned PDFs is intentionally deferred in V1.