Skip to main content
Glama
Aegis MCP Server
by CJH91577

๐Ÿ›ก๏ธ Aegis โ€” Enterprise-Grade AI Agent Platform

Multi-format document RAG ยท Multi-agent collaboration ยท MCP tool invocation ยท Fact-checking with self-correction ยท HITL human approval

Aegis (/หˆiหdส’ษชs/, Shield) is an out-of-the-box enterprise-grade AI agent application, designed around two main pillars: "Trustworthy Answers" and "Safe Execution":

  • Answer side: Multi-agent (Planner โ†’ Retriever โ†’ Auditor โ†’ Answerer) division of labor, every answer goes through Auditor fact-checking; when evidence is insufficient, it states so honestly and never fabricates;

  • Execution side: Tool invocation is based on the standardized MCP (Model Context Protocol), combined with least-privilege whitelist + human approval for sensitive operations (HITL) to achieve secure isolation.

                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚                ็”จๆˆท / FastAPI / CLI            โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                           โ”‚ ๆ้—ฎ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚           Orchestrator๏ผˆๅคšๆ™บ่ƒฝไฝ“็ผ–ๆŽ’ๅ™จ๏ผ‰        โ”‚
                    โ”‚                                              โ”‚
                    โ”‚  โ‘  Planner    ่ง„ๅˆ’๏ผšๆ‹†่งฃๅญ้—ฎ้ข˜ + ๅทฅๅ…ท่ฎกๅˆ’        โ”‚
                    โ”‚  โ‘ก Retriever  ๆฃ€็ดข๏ผšๆททๅˆๆฃ€็ดข + MCP ๅทฅๅ…ทๆ‰ง่กŒ      โ”‚
                    โ”‚  โ‘ข Answerer   ่ตท่‰๏ผšๅŸบไบŽ่ฏๆฎใ€ๅธฆๅผ•็”จ [C1][C2]   โ”‚
                    โ”‚  โ‘ฃ Auditor    ๆ ธๆŸฅ๏ผš้€ๆกๅฃฐๆ˜Ž vs ่ฏๆฎ            โ”‚
                    โ”‚       โ””โ”€ revise โ”€โ–บ ๅธฆๅ้ฆˆ้‡ๆฃ€/้‡็ญ”๏ผˆโ‰ค3 ่ฝฎ๏ผ‰     โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚ ่ฏญไน‰ๆฃ€็ดข                       โ”‚ MCP ๅ่ฎฎ
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ”‚  ็Ÿฅ่ฏ†ๅบ“๏ผˆRAG๏ผ‰           โ”‚       โ”‚   MCP ๅทฅๅ…ทๆœๅŠกๅ™จ        โ”‚
              โ”‚  PDF/DOCX/XLSX/PPTX/TXTโ”‚       โ”‚  calculator / kb_search โ”‚
              โ”‚  โ†’ ่งฃๆž โ†’ ๅˆ‡ๅ— โ†’ ๅ‘้‡ๅŒ–  โ”‚       โ”‚  doc_stats / โ€ฆ          โ”‚
              โ”‚  โ†’ Chroma + BM25 ๆททๅˆ   โ”‚       โ”‚  ๐Ÿ”’ ๆ•ๆ„Ÿๅทฅๅ…ท โ†’ HITL ๅฎกๆ‰น โ”‚
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โœจ Core Capabilities

Requirement

Implementation

Multi-format document knowledge ingestion and semantic retrieval

PDF / Word / Excel / PPT / TXT parsing (including tables, slides, page-number positioning); recursive chunking; vector + BM25 hybrid retrieval (RRF fusion); local embeddings with no API Key required

Multi-agent division of labor

Planner (planning) โ†’ Retriever (retrieval + tools) โ†’ Answerer (drafting with citations) โ†’ Auditor (verification); on audit failure, automatically re-retrieves/answers with feedback, up to N rounds

MCP-based standardized tool invocation with secure isolation

MCP server implemented on the official mcp SDK (supports both in-process and standard stdio access); JSON Schema parameter validation; per-agent least-privilege whitelist; AST whitelist calculator to eliminate injection

Auditor fact-checking and self-correction

Verifies each claim against evidence (supported/unsupported/contradicted) line by line, outputs confidence scores and revision suggestions; when evidence is insufficient, explicitly states so and refuses to fabricate, and may autonomously supplement retrieval

HITL human intervention

Sensitive tools (send email/export/delete) trigger approval-request suspension, with execution resuming after approve/reject; three modes: interactive / auto_approve / auto_deny (deny by default, fail-safe)

Related MCP server: Works With Agents MCP Server

๐Ÿš€ Quick Start

# 1. ๅฎ‰่ฃ…๏ผˆPython 3.10+๏ผ‰
cd enterprise-rag-agent
pip install -e .

# 2.๏ผˆๅฏ้€‰๏ผ‰้…็ฝฎ LLM โ€”โ€” ้ป˜่ฎค็ฆป็บฟๆจกๅผๆ— ้œ€้…็ฝฎ๏ผ›ๆŽฅๅ…ฅ็œŸๅฎžๆจกๅž‹่งไธ‹ๆ–‡
cp .env.example .env   # ๅกซๅ…ฅ OPENAI ๅ…ผๅฎน็š„ API Key๏ผˆOpenAI/DeepSeek/Ollama ็ญ‰๏ผ‰

# 3. ไธ€้”ฎ็ซฏๅˆฐ็ซฏๆผ”็คบ๏ผˆ่‡ชๅŠจ็”Ÿๆˆ 5 ็งๆ ผๅผๆ ทไพ‹ๆ–‡ๆกฃ โ†’ ๅ…ฅๅบ“ โ†’ ้—ฎ็ญ” โ†’ ๅฎกๆ‰น๏ผŒๅ…จ้ƒจ่‡ชๆ ก้ชŒ๏ผ‰
aegis demo

# 4. ๅฏผๅ…ฅไฝ ่‡ชๅทฑ็š„ๆ–‡ๆกฃ
aegis ingest ./your_docs

# 5. ๆ้—ฎ๏ผˆๅคšๆ™บ่ƒฝไฝ“ๆตๆฐด็บฟ๏ผ‰
aegis ask "ไธ€็บฟๅŸŽๅธ‚ๅ‡บๅทฎไฝๅฎฟๆŠฅ้”€ไธŠ้™ๆ˜ฏๅคšๅฐ‘๏ผŸ"

# 6. ๅฏๅŠจ HTTP ๆœๅŠก๏ผˆSwagger: http://127.0.0.1:8000/docs๏ผ‰
aegis serve

Run the full pipeline with no API Key required: the default embedding model uses a local ONNX (BAAI/bge-small-zh-v1.5, ~95MB auto-downloaded on first run), and the LLM uses a built-in deterministic backend for end-to-end verification; to connect a real model, simply configure it in .env.

Connecting a Real LLM

Supports any OpenAI-compatible protocol endpoint:

# OpenAI / DeepSeek / ้€šไน‰ / ๆœฌๅœฐ vLLM
AEGIS_LLM_PROVIDER=openai
AEGIS_LLM_BASE_URL=https://api.deepseek.com/v1
AEGIS_LLM_API_KEY=sk-xxxx
AEGIS_LLM_MODEL=deepseek-chat

# ๆˆ–ๆœฌๅœฐ Ollama๏ผˆๅซๅตŒๅ…ฅ๏ผŒๅฎŒๅ…จ็ฆป็บฟ๏ผ‰
AEGIS_LLM_PROVIDER=ollama
AEGIS_LLM_MODEL=qwen2.5:3b
AEGIS_EMBED_PROVIDER=ollama
AEGIS_EMBED_MODEL=nomic-embed-text

๐Ÿ“– Documentation

Document

Content

docs/architecture.md

Architecture design, multi-agent collaboration protocol, security model

docs/deploy.md

Deployment, configuration, LLM integration, MCP stdio mode

docs/verification.md

End-to-end self-verification report and verification methods

๐Ÿ”Œ HTTP API

Method

Path

Description

POST

/api/documents/ingest

Upload document for ingestion (multipart)

POST

/api/documents/ingest-path

Batch ingestion by path

GET

/api/documents

Document list

DELETE

/api/documents/{id}

Delete document (sensitive โ†’ HITL)

POST

/api/chat

Ask a question (multi-agent pipeline)

GET

/api/sessions/{id}

Session status

POST

/api/sessions/{id}/resume

Resume session after approval

GET

/api/approvals

Approval-request list

POST

/api/approvals/{id}/decide

Approve/reject ({"approve": true})

GET

/api/tools ยท POST /api/tools/call

MCP tool catalog / manual tool invocation

GET

/health

Health check

๐Ÿงฉ MCP Tools

Exposed via the standard Model Context Protocol, accessible by any MCP client:

python -m aegis.mcp.server   # ๆ ‡ๅ‡† stdio ๆœๅŠก

Tool

Description

Security Level

calculator

AST whitelist safe calculation

โœ… Regular

get_current_time

Current time

โœ… Regular

kb_search

Knowledge base semantic retrieval

โœ… Regular

doc_stats

Knowledge base statistics

โœ… Regular

send_email

Simulated email sending

๐Ÿ”’ Sensitive โ†’ HITL

export_file

Export file (sandbox directory)

๐Ÿ”’ Sensitive โ†’ HITL

delete_document

Delete document

๐Ÿ”’ Sensitive โ†’ HITL

๐Ÿงช Testing and Verification

pip install -e ".[dev]"
pytest -q              # ๅ•ๅ…ƒ + ้›†ๆˆๆต‹่ฏ•๏ผˆๅ…จ้ƒจ็ฆป็บฟๅฏ่ท‘๏ผ‰
aegis demo             # ็ซฏๅˆฐ็ซฏๆผ”็คบ๏ผˆๅซ 20+ ๆก่‡ชๆ ก้ชŒๆ–ญ่จ€๏ผ‰

๐Ÿ“ Directory Structure

enterprise-rag-agent/
โ”œโ”€โ”€ aegis/
โ”‚   โ”œโ”€โ”€ llm/            # LLM ๆŠฝ่ฑกๅฑ‚๏ผˆOpenAI ๅ…ผๅฎน / Ollama / ็ฆป็บฟ็กฎๅฎšๆ€ง๏ผ‰
โ”‚   โ”œโ”€โ”€ embeddings/     # ๅตŒๅ…ฅๅฑ‚๏ผˆfastembed ๆœฌๅœฐ / OpenAI / Ollama๏ผ‰
โ”‚   โ”œโ”€โ”€ ingestion/      # ่งฃๆž๏ผˆ5 ๆ ผๅผ๏ผ‰โ†’ ๅˆ‡ๅ— โ†’ ๅ…ฅๅบ“็ฎก้“
โ”‚   โ”œโ”€โ”€ retrieval/      # Chroma ๅ‘้‡ๅบ“ + BM25 ๆททๅˆๆฃ€็ดข
โ”‚   โ”œโ”€โ”€ mcp/            # MCP ๆœๅŠกๅ™จ / ๅฎขๆˆท็ซฏ / ๅฎ‰ๅ…จ็ญ–็•ฅ
โ”‚   โ”œโ”€โ”€ agents/         # Planner / Retriever / Answerer / Auditor
โ”‚   โ”œโ”€โ”€ hitl/           # ไบบๅทฅๅฎกๆ‰น็ฎก็†ๅ™จ
โ”‚   โ”œโ”€โ”€ api/            # FastAPI ๆœๅŠก
โ”‚   โ”œโ”€โ”€ orchestrator.py # ๅคšๆ™บ่ƒฝไฝ“็ผ–ๆŽ’ๅ™จ๏ผˆ็Šถๆ€ๆœบ + ๆŒ‚่ตทๆขๅค๏ผ‰
โ”‚   โ”œโ”€โ”€ demo.py         # ็ซฏๅˆฐ็ซฏๆผ”็คบ
โ”‚   โ””โ”€โ”€ cli.py          # ๅ‘ฝไปค่กŒๅ…ฅๅฃ
โ”œโ”€โ”€ scripts/make_sample_docs.py   # ๆ ทไพ‹ๆ–‡ๆกฃ็”Ÿๆˆ
โ”œโ”€โ”€ tests/              # pytest ๅฅ—ไปถ
โ””โ”€โ”€ docs/               # ๆžถๆž„ / ้ƒจ็ฝฒ / ้ชŒ่ฏๆ–‡ๆกฃ

โš ๏ธ Security Notes

  • Sensitive tools are denied by default (auto_deny); for production environments, it is recommended to keep interactive human approval;

  • export_file only allows writing to the exports/ sandbox under the data directory;

  • The calculator uses AST whitelist evaluation, with no eval injection surface;

  • The project's send_email is a simulated implementation; before connecting a real email gateway, implement it yourself and keep HITL approval in place.

๐Ÿ“„ License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelogโ€ฆ

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      A secure MCP gateway for enterprise AI tool execution, enabling governed invocation of business tools with authentication, RBAC, audit logging, PII redaction, and async processing.
      Apache 2.0
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to securely call enterprise MCP tools with tenant-scoped RBAC, human approvals, audit logging, and multi-tool workflows across customer, order, document, and ticket data.
      -
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables an AI assistant to dynamically discover and invoke MCP tools for document search, employee information lookup, and mathematical calculations, with human-in-the-loop approval for sensitive operations.
      -