ACG Mcp

by kos-m

Not rated
GitHub

About

Standalone MCP server for the Audited Context Generation (ACG) Protocol — verifiable fact-checking and grounded RAG via MongoDB.

Details

Author
kos-m
Categories
Search, Knowledge Base, Database, Other

Option A: Virtual environment + editable install (recommended)

git clone https://github.com/Kos-M/acg_mcp.git cd acg_mcp python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -e .

This installs the package and its dependencies into the venv and puts theacg-mcpcommand on PATHwhile the venv is active. Editable mode means local code changes apply immediately — no reinstall needed.

MCP clients don't source your shell, so point them at the venv's binary by absolute path instead of relying on PATH (see](#two-ways-to-use-acg)Connect from an MCP client).

Option B: System-wide install (agents / CLI tools)

If you wantacg-mcpavailable on PATH fromanydirectory without a venv:

git clone https://github.com/Kos-M/acg_mcp.git cd acg_mcp pip install -e .

If pip fails withexternally-managed-environment(PEP 668), either use a venv (Option A) or add--break-system-packages.

git clone https://github.com/Kos-M/acg_mcp.git cd acg_mcp pip install -r requirements.txt # Must be run from the project root: python -m src.server
# MongoDB connection string (required) MONGO_URI=mongodb://localhost:27017 # MongoDB database name (optional, default: acg_protocol) MONGO_DB=acg_protocol # Embedding model cache directory (optional) EMBEDDING_CACHE_DIR= # Vector search candidate cap (optional, default: 10000). # Number of embedded chunks scanned per query. Raise it if your index # exceeds this and you see false "LOW confidence" results. ACG_VECTOR_MAX_CANDIDATES=10000
MONGO_URI=mongodb+srv://<user>:<password>@<cluster>.mongodb.net/acg_protocol?retryWrites=true&w=majority
# venv (Option A): works while the venv is active # system-wide (Option B): works from any directory acg-mcp

Without installing the CLI (source directory only):

cd /path/to/acg_mcp python -m src.server

The one-shot CLI runs the entire audited pipeline without an MCP client:

# Query the index, print the grounded answer + audit footer acg-mcp --workflow "What does the README say about MONGO_URI?" # Same, but auto-index a URL first when confidence is LOW acg-mcp --workflow "How do I configure MongoDB Atlas?" https://example.com/docs/setup

The server communicates overstdio. Claude Desktop and Opencode usedifferentconfig formats, so the examples below are split per client: Claude Desktop uses themcpServerskey; Opencode uses a top-levelmcpkey where every server needs"type"andcommandis an array.

Claude Desktop readsclaude_desktop_config.jsonand uses themcpServerskey. If you installed withOption A(venv), point at the venv binary — clients don't source your shell:

{ "mcpServers": { "acg-mcp": { "command": "/absolute/path/to/acg_mcp/venv/bin/acg-mcp", "env": { "MONGO_URI": "mongodb+srv://..." } } } }

With a system-wide install (Option B), the bare command works directly:

{ "mcpServers": { "acg-mcp": { "command": "acg-mcp", "env": { "MONGO_URI": "mongodb+srv://..." } } } }

Opencode readsopencode.json(oropencode.jsonc) and uses a top-levelmcpkey. Local servers require"type": "local",commandas anarrayof the binary + args, and env vars under"environment"(not"env"):

{ "$schema": "https://opencode.ai/config.json", "mcp": { "acg-mcp": { "type": "local", "command": ["/absolute/path/to/acg_mcp/venv/bin/acg-mcp"], "enabled": true, "environment": { "MONGO_URI": "mongodb+srv://..." } } } }

With a system-wide install (Option B), use the bare command:

{ "$schema": "https://opencode.ai/config.json", "mcp": { "acg-mcp": { "type": "local", "command": ["acg-mcp"], "enabled": true, "environment": { "MONGO_URI": "mongodb+srv://..." } } } }

If you haven't installed the CLI, use the full path. Claude Desktop:

{ "mcpServers": { "acg-mcp": { "command": "python", "args": ["-m", "src.server"], "env": { "MONGO_URI": "mongodb+srv://..." } } } }

Opencode — notecwdsosrc.serverresolves relative to the project:

{ "$schema": "https://opencode.ai/config.json", "mcp": { "acg-mcp": { "type": "local", "command": ["python", "-m", "src.server"], "cwd": "/path/to/acg_mcp", "environment": { "MONGO_URI": "mongodb+srv://..." } } } }

Important:When usingpython -m src.server, run the MCP client from the project root (/path/to/acg_mcp) or setcwdin the MCP config.

ACG shipsbothan enforced end-to-end workflow and the individual tools it is built from. Use whichever fits your task.

Standalone MCP serverfor theAudited Context Generation (ACG) Protocol— verifiable fact-checking and grounded RAG via MongoDB.

ACG provides a dual-layer standard for veracity assurance:

- UGVP (Layer 1): Atomic fact grounding with Claim Markers and Source Hash Identity (SHI)
- RSVP (Layer 2): Logical synthesis verification with Relationship Markers

LLMs confidently state things that are wrong, and there is usuallyno way to check— the answer is a black box with no provenance. ACG fixes this by making every answerauditable by construction:

-

Ground every fact to its source.Index a URL once and every later answer built from it carries inline Claim Markers like[C1:9f7a2c4d8e1b:css=#acg-chunk-aa-0]— the SHA-256-based SHI prefix fingerprints the exact source document, and the CSS selector points to the precise chunk inside it.

Verify instead of trust.acg_verify_claimsre-fetches every source and fuzzy-matches each claim against the actual text, so verification is not a self-reported LLM opinion — it is an independent, repeatable check. A claim either exists in the cited source or it fails.

Know when the knowledge base is enough.acg_check_indexedreturns a confidence score (HIGH / MEDIUM / LOW) before you ever hit the network, so you only fetch new pages when the index genuinely can't answer.

Get a machine-readable audit trail.acg_build_varemits a Veracity Audit Registry (SSR + RAR entries) — a JSON record of every claim, its source fingerprint, and every logical relationship between claims, ready to be consumed by downstream systems or humans.

Use it in two modes.Run theenforced workflow(acg_run_workflow) and get a complete, verified, audited answer in one call — or compose the individual tools any way your own workflow requires (seeTwo ways to use ACG).

In short: ACG turns "trust me, the model said so" into"here is the claim, here is the exact source location, here is the verification result, and here is the audit record."

- Enforced workflow→ One call runs the whole pipeline: search, auto-index, ground, verify, audit (seeTwo ways to use ACG)
- Index URLs→ Extract text, chunk by sentences, generate embeddings, store in MongoDB
- Search Sources→ Semantic (vector) + keyword search across indexed content
- Check Indexed→ Confidence-scored lookup to avoid unnecessary web_fetch calls
- Generate Grounded Text→ Create verifiable output with inline Claim Markers
- Verify Claims→ Re-fetch sources, fuzzy-match claims against source text
- Build VAR→ Generate machine-readable Veracity Audit Registry (SSR + RAR)
- Crawl & Index→ BFS URL discovery + automatic ACG indexing pipeline
- Reset Database→ Drop all ACG collections (with confirmation guard)

- Python 3.11+
- MongoDB instance (local or Atlas)

- Atlas Vector Search isoptional— falls back to keyword search if no embedding model

RequiresPython 3.11+. A virtual environment isstrongly recommended— on recent Debian/Ubuntu (23.04+) and other PEP 668 distros, barepip installrefuses to write to the system Python, so Option A is the reliable path there.

Option A: Virtual environment + editable install (recommended)

git clone https://github.com/Kos-M/acg_mcp.git cd acg_mcp python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -e .

This installs the package and its dependencies into the venv and puts theacg-mcpcommand on PATHwhile the venv is active. Editable mode means local code changes apply immediately — no reinstall needed.

MCP clients don't source your shell, so point them at the venv's binary by absolute path instead of relying on PATH (seeConnect from an MCP client).

Option B: System-wide install (agents / CLI tools)

If you wantacg-mcpavailable on PATH fromanydirectory without a venv:

git clone https://github.com/Kos-M/acg_mcp.git cd acg_mcp pip install -e .

If pip fails withexternally-managed-environment(PEP 668), either use a venv (Option A) or add--break-system-packages.

git clone https://github.com/Kos-M/acg_mcp.git cd acg_mcp pip install -r requirements.txt # Must be run from the project root: python -m src.server
# MongoDB connection string (required) MONGO_URI=mongodb://localhost:27017 # MongoDB database name (optional, default: acg_protocol) MONGO_DB=acg_protocol # Embedding model cache directory (optional) EMBEDDING_CACHE_DIR= # Vector search candidate cap (optional, default: 10000). # Number of embedded chunks scanned per query. Raise it if your index # exceeds this and you see false "LOW confidence" results. ACG_VECTOR_MAX_CANDIDATES=10000
MONGO_URI=mongodb+srv://<user>:<password>@<cluster>.mongodb.net/acg_protocol?retryWrites=true&w=majority
# venv (Option A): works while the venv is active # system-wide (Option B): works from any directory acg-mcp

Without installing the CLI (source directory only):

cd /path/to/acg_mcp python -m src.server

The one-shot CLI runs the entire audited pipeline without an MCP client:

# Query the index, print the grounded answer + audit footer acg-mcp --workflow "What does the README say about MONGO_URI?" # Same, but auto-index a URL first when confidence is LOW acg-mcp --workflow "How do I configure MongoDB Atlas?" https://example.com/docs/setup

The server communicates overstdio. Claude Desktop and Opencode usedifferentconfig formats, so the examples below are split per client: Claude Desktop uses themcpServerskey; Opencode uses a top-levelmcpkey where every server needs"type"andcommandis an array.

Claude Desktop readsclaude_desktop_config.jsonand uses themcpServerskey. If you installed withOption A(venv), point at the venv binary — clients don't source your shell:

{ "mcpServers": { "acg-mcp": { "command": "/absolute/path/to/acg_mcp/venv/bin/acg-mcp", "env": { "MONGO_URI": "mongodb+srv://..." } } } }

With a system-wide install (Option B), the bare command works directly:

{ "mcpServers": { "acg-mcp": { "command": "acg-mcp", "env": { "MONGO_URI": "mongodb+srv://..." } } } }

Opencode readsopencode.json(oropencode.jsonc) and uses a top-levelmcpkey. Local servers require"type": "local",commandas anarrayof the binary + args, and env vars under"environment"(not"env"):

{ "$schema": "https://opencode.ai/config.json", "mcp": { "acg-mcp": { "type": "local", "command": ["/absolute/path/to/acg_mcp/venv/bin/acg-mcp"], "enabled": true, "environment": { "MONGO_URI": "mongodb+srv://..." } } } }

With a system-wide install (Option B), use the bare command:

{ "$schema": "https://opencode.ai/config.json", "mcp": { "acg-mcp": { "type": "local", "command": ["acg-mcp"], "enabled": true, "environment": { "MONGO_URI": "mongodb+srv://..." } } } }

If you haven't installed the CLI, use the full path. Claude Desktop:

{ "mcpServers": { "acg-mcp": { "command": "python", "args": ["-m", "src.server"], "env": { "MONGO_URI": "mongodb+srv://..." } } } }

Opencode — notecwdsosrc.serverresolves relative to the project:

{ "$schema": "https://opencode.ai/config.json", "mcp": { "acg-mcp": { "type": "local", "command": ["python", "-m", "src.server"], "cwd": "/path/to/acg_mcp", "environment": { "MONGO_URI": "mongodb+srv://..." } } } }

Important:When usingpython -m src.server, run the MCP client from the project root (/path/to/acg_mcp) or setcwdin the MCP config.

ACG shipsbothan enforced end-to-end workflow and the individual tools it is built from. Use whichever fits your task.

1. Enforced workflow — the whole protocol in one call

Callacg_run_workflow(query, url="")and the server runs the full pipeline for you, in this order:
- search— search the indexed sources for the query
- index— if confidence is LOW and aurlwas provided, index it first, then re-search (auto-fetch)
- ground— compose a grounded answer with inline UGVP Claim Markers
- verify— re-fetch every cited source and fuzzy-match each claim
- audit— build the Veracity Audit Registry (SSR + RAR)

The single returned report contains everything: the grounded answer, per-claim verification results, aChunk Signatures Table, and the audit footer —[Claims Verified: x/y],[ACG Accuracy: N%],[ACG Signed: ACG Protocol]. You get a verifiable answer without orchestrating any of the steps yourself.

// acg_run_workflow("What is the pricing of the flash model?") { "query": "What is the pricing of the flash model?", "workflow": ["search", "ground", "verify", "audit"], "confidence_tier": "HIGH", "grounded_answer": "Flash input tokens cost $0.14 per 1M [C1:9f7a2c4d8e1b:css=#acg-chunk-aa-0].", "claims_verified": "1/1", "acg_accuracy": 100.0, "acg_signed": "ACG Protocol", "var": { "protocol": "ACG/1.0", "ssr_entries": [ / ... / ], "rar_entries": [] } }

2. Individual tools — adapt ACG to your own workflow

Every step is also available as a standalone tool, so you can compose exactly the pipeline your workflow needs — different chunking, custom verification thresholds, your own retrieval strategy, or ACG used purely as a post-generation audit layer.

For example, a "verify-only" workflow that audits text generated elsewhere:

acg_generate_grounded_text(claim, shi_prefix, css_selector) -> acg_verify_claims(grounded_text) -> acg_build_var(grounded_text)

Once installed withOption A(venv) orOption B(system-wide), any tool or agent on the machine can use acg-mcp by referencing it in their MCP configuration. Add it to the agent's global Opencode config (~/.config/opencode/opencode.json) using Opencode'smcpsyntax:

{ "$schema": "https://opencode.ai/config.json", "mcp": { "acg-mcp": { "type": "local", "command": ["acg-mcp"], "enabled": true, "environment": { "MONGO_URI": "mongodb://localhost:27017" } } } }

The agent can then call ACG tools directly:

- acg_run_workflow()— One call: full verified, audited answer
- acg_check_indexed()— Check if answers exist in indexed sources
- acg_index_url()— Index new URLs
- acg_verify_claims()— Verify grounded text claims
- acg_search_sources()— Search indexed knowledge base

PassMONGO_URIand other config via theenvfield (Claude Desktop) orenvironmentfield (Opencode) in the MCP config. The server also loads.envfrom the project directory (via python-dotenv) when installed editable (pip install -e .) or run from the project root.

The server uses a standard MongoDB collection structure:

Indexes are auto-created on first connection.

Search global news using natural language. Webz.io News Search API returns the most relevant articles and content, with filters for source, country, language, date, sentiment, and category.

A vector database server powered by Chroma, enabling semantic document search, metadata filtering, and document management.

Deterministic O(1) memory for AI agents — local-first, MCP-native, with multi-agent speaker attribution and millisecond recall.

A free, plug-and-play knowledge base with over 10,000 built-in insight reports and support for parsing private documents.

Interact with on-disk documents using agentic RAG and hybrid search via LanceDB.

Manage and query custom knowledge bases using webhook endpoints.

Integrates with Mem0.ai to provide persistent memory capabilities for LLMs, supporting cloud, Supabase, and local storage.

Enables Large Language Models to store and retrieve persistent memories with intelligent search capabilities.

A high-performance, persistent knowledge base MCP server built with Rust. Supports local deployment with hybrid datastores like Qdrant, Neo4j, and Redis.

MCP server for searching 600,000+ CS/AI research papers with citation graphs, full text, embeddings, and BibTeX.

RAG Search over your content powered by Inkeep

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.