Skip to main content
Glama

🔌 MCP Docs Assistant

공식 Model Context Protocol 문서를 기반으로 하는 프로덕션급 검색·증강 생성(RAG) 파이프라인 — REST, MCP 도구, Docker로 제공됩니다.

MCP(아키텍처, 서버/클라이언트 구축, 도구/리소스/프롬프트, 보안)에 대해 자연어로 질문하고 실제 문서에 근거한 답변을 얻을 수 있습니다. 가드레일, PII 마스킹, 재랭킹, 시맨틱 캐시, 환각 검사가 기본으로 내장되어 있습니다.


✨ 기능

기능

구현 방식

🔀 멀티 키 LLM 게이트웨이

Portkey 라우팅, Gemini 키 2개 + Groq 키 2개로 부하 분산, 자동 공급자 폴백

📚 근거 기반 검색

공식 MCP 문서를 청킹하여 영속적인 Qdrant 벡터 스토어에 임베딩

🎯 재랭킹

크로스 인코더(ms-marco-MiniLM-L-6-v2)가 넓은 후보 풀을 가장 관련성 높은 청크로 압축

🛡️ 가드레일

NeMo Guardrails(Colang 2.x) — 입력/출력 안전 검사, 탈옥(jailbreak) 및 지침 유출 감지

🕵️ PII 마스킹

Microsoft Presidio — 입력과 출력 모두에서 이메일, 전화번호, 신용카드 마스킹

🧮 토큰 예산 관리

검색된 컨텍스트를 LLM 호출 전에 고정 토큰 예산에 맞게 탐욕적으로 조정

시맨틱 캐시

정확히 일치하지 않아도 임베딩 유사도 기반 캐시, TTL + 크기 상한

💬 멀티턴 대화

LangGraph 체크포인터 + 후속 쿼리 압축("그것의 Python 예제를 보여줘")

🔍 환각 검사

생성된 모든 답변에 대해 GROUNDED / HALLUCINATED 런타임 LLM-as-judge 판정

📊 오프라인 평가

RAGAS 지표(충실성, 관련성, 컨텍스트 정밀도/재현율)를 25개 참조 Q&A 쌍 기준으로 평가

🔌 MCP 네이티브

자체를 MCP 도구(ask_mcp_docs, search_mcp_docs, …)로 노출 — Claude Desktop, Claude Code 또는 모든 MCP 호스트에서 바로 사용 가능

🌐 REST API

일반 HTTP 클라이언트용 FastAPI 엔드포인트

🐳 Docker 지원

docker compose up 한 번으로 배포


Related MCP server: FusionPact MCP Server

🏗️ 아키텍처

flowchart TD
    A[User Question] --> B[Guard Input<br/>NeMo Guardrails]
    B -->|blocked| Z[Refusal message]
    B -->|allowed| C[Mask Input PII<br/>Presidio]
    C --> D[Condense Follow-up<br/>into standalone question]
    D --> E{Semantic<br/>Cache Hit?}
    E -->|yes| F[Return cached answer]
    E -->|no| G[Retrieve Top-15<br/>Qdrant Vector Store]
    G --> H[Rerank Top-5<br/>Cross-Encoder]
    H --> I[Fit to Token Budget]
    I --> J[Generate Answer<br/>Portkey: Gemini / Groq]
    J --> K[Guard Output<br/>leak / PII pattern check]
    K --> L[Hallucination Check<br/>LLM-as-judge]
    L --> M[Mask Output PII]
    M --> N[Cache + Store History]
    N --> O[Return Answer]

위의 모든 노드는 rag_pipeline/ 안의 모듈이며, rag_pipeline/graph.py의 LangGraph StateGraph로 연결됩니다. rag_core.py는 모든 의존성을 한 번(싱글턴) 만든 뒤 작고 안정적인 API — chat(), search(), get_history(), cache_stats() — 를 제공합니다. 이 API는 REST 레이어(main.py)와 MCP 레이어(mcp_server.py)가 동일하게 사용하므로, 어느 인터페이스로 요청이 들어와도 하나의 벡터 스토어 / 캐시 / 대화 기록이 공유됩니다.


📁 프로젝트 구조

mcp-docs-rag-assistant/
├── main.py                    # FastAPI app — REST endpoints + mounts MCP at /mcp
├── mcp_server.py               # MCP tools (stdio standalone, or mounted in main.py)
├── rag_core.py                 # Singleton facade wiring the whole pipeline together
├── rag_pipeline/
│   ├── config.py                 # Env vars / secrets (single source of truth)
│   ├── logging_setup.py          # Logging + Logfire
│   ├── gateway.py                 # Portkey multi-key LLM gateway
│   ├── errors.py                   # Retry + safe-node error handling
│   ├── ingestion.py                 # MCP docs loader + splitter
│   ├── vectorstore.py                # Embeddings + persistent Qdrant store
│   ├── reranker.py                    # Cross-encoder reranking
│   ├── pii_masking.py                  # Presidio PII masking
│   ├── guardrails.py                    # NeMo Guardrails (Colang 2.x)
│   ├── token_management.py               # Context window budgeting
│   ├── semantic_cache.py                  # Embedding-similarity cache
│   ├── query_condensation.py               # Follow-up question rewriting
│   ├── hallucination.py                     # Runtime hallucination judge
│   └── graph.py                              # LangGraph StateGraph — full pipeline
├── scripts/
│   └── evaluate_ragas.py        # Offline RAGAS evaluation (25 reference Q&A)
├── tests/
│   └── test_pipeline.py         # Fast smoke tests (no API keys needed)
├── configs/guardrails/           # Colang rail files (generated at first run)
├── data/                          # Persisted Qdrant vector store (gitignored)
├── notebooks/                      # Original development notebook
├── Dockerfile
├── docker-compose.yml
├── requirements.txt
└── .env.example

🚀 시작하기

사전 요구사항

1. 리포지토리 클론 및 가상환경 설정

git clone https://github.com/<your-username>/mcp-docs-rag-assistant.git
cd mcp-docs-rag-assistant
python -m venv venv
venv\Scripts\activate          # Windows
# source venv/bin/activate     # macOS/Linux

2. 의존성 설치

pip install -r requirements.txt
python -m spacy download en_core_web_sm   # required by Presidio for PII detection

3. 환경 변수 설정

cp .env.example .env

.env 파일을 열고 실제 키(GEMINI_API_KEY_1/2, GROQ_API_KEY_1/2, PORTKEY_API_KEY, PORTKEY_CONFIG_ID)를 입력하세요.

4. 서버 실행

uvicorn main:app --reload

첫 실행에만 : 벡터 스토어가 아직 없으므로 서버가 MCP 문서를 읽어들이고 rate-limited 배치로 임베딩합니다. 이 작업은 5–10분 정도 걸릴 수 있습니다. 이후 실행부터는 data/qdrant_mcp_db/에 저장된 벡터 스토어를 즉시 사용합니다.

Startup: RAG pipeline ready. 메시지가 표시되면 다음 주소를 열어보세요.

  • http://localhost:8000/docs — 인터랙티브 Swagger UI, POST /chat 시도 가능

  • http://localhost:8000/health — 헬스 체크


📡 REST API

메서드

엔드포인트

설명

POST

/chat

질문을 보냅니다. 요청 본문: {"question": "...", "thread_id": "..."}

POST

/search

검색 + 랭킹 후 원본 컨텍스트를 반환하고 생성은 하지 않습니다. 요청 본문: {"query": "...", "top_n": 5}

GET

/history/{thread_id}

특정 스레드의 대화 기록을 가져옵니다.

GET

/cache/stats

시맨틱 캐시 관찰용 지표

GET

/health

헬스 체크


🔌 MCP 서버로 사용하기

단독 실행(stdio) — Claude Desktop용

직접 실행:

python mcp_server.py

또는 로컬 MCP 호스트가 이 서버를 디스플레이하도록 할 수도 있습니다. 예를 들어 Claude Desktop 설정 파일(claude_desktop_config.json)에 다음과 같이 추가하세요.

{
  "mcpServers": {
    "mcp-docs-assistant": {
      "command": "python",
      "args": ["E:\\mcp-docs-rag-assistant\\mcp_server.py"]
    }
  }
}

원격(streamable-http) — FastAPI 경유

main.py가 실행 중이면 동일한 MCP 도구를 다음 주소로 사용할 수 있습니다.

http://localhost:8000/mcp

제공 도구: ask_mcp_docs, search_mcp_docs, get_conversation_history, cache_stats.


🐳 Docker

유일한 사전 요구사항은 Docker Desktop(Docker Compose 포함)입니다. 로컬 머신에 Python, pip 의존성, spacy 모델 등을 별도 설치는 로컬 머에서 하지 않아도 됩니다. 이미지 빌드 시 그 모 게 자동으로 수행됩니다(Dockerfile 참조 — 빌드 단계에서 pip install -r requirements.txtpython -m spacy download en_core_web_sm 단계가 있습니다).

# 1. Make sure .env exists (same as the local setup, step 3 above)
cp .env.example .env   # then fill in real keys

# 2. Build and run
docker compose up --build

이 명령 하나로 이미지를 빌드하고 그 안에 모든 것을 설치하며 컨테이너를 시작합니다. data/ 폴더는 볼륨으로 마운트되므로(docker-compose.yml 참조) 벡터 스토어가 컨테이너 재시작 후에도 지속됩니다. Docker를 통해서도 느린 첫 실행 로딩 비용은 한 번만 부담하면 됩니다.

서버 접근 방법은 로컬 실행과 동일합니다. http://localhost:8000/docs .

중지하려면:

docker compose down

코드나 종속성을 변경한 후 다시 빌드로 하려면:

docker compose up --build

🧪 테스트

빠른 스모크 테스트 — API 키나 네트워크 호출 없이 실행됩니다(가짜 임베딩 사용).

pip install pytest
pytest tests/ -v

📊 오프라인 평가 (RAGAS)

획득 참조 답변이 있는 25개의 수·작성 MCP 질문에 대해 RAGAS로 파이프라인을 점검합니다.

python scripts/evaluate_ragas.py

서버가 실행 중일 필요는 없습니다 — 스스로 파이프라인을 구성(main.py/mcp_server.py와 동일한 싱글턴을 사용)하여 지표 표를 출력합니다.

  • 충실성(Faithfulness) — 답변이 검색된 컨텍스트에 근거했는가?

  • 응답 관련성(Response Relevancy) — 답변이 실제 질문에 충실히 답하는가?

  • 컨텍스트 정밀도(Context Precision) — 검색된 컨텍스트가 관련 있는가?

  • 컨텍스트 재현율(Context Recall) — 검색된 컨텍스트가 참고 답변에 필요한 정보를 포함하고 있는가?

⏱️ 몇 분 정도 걸립니다. 25개 질문 각각에 실제 검색 + 생성 패스를 수행하며 이후 각 지표는 LLM-as-judge 호출로 평가됩니다.


⚙️ 환경 설정 참조

모든 구성은 .env 파일에 위치합니다(.env.example 참조). 주요 변수:

변수

용도

GEMINI_API_KEY_1/2, GROQ_API_KEY_1/2

프로바이더 키. Portkey를 통해 부하 라우팅

PORTKEY_API_KEY, PORTKEY_CONFIG_ID

Portkey 게이트웨이 자격 증명 + 라우팅 설정

QDRANT_PATH, QDRANT_COLLECTION

벡터 스토어 경로/이름

LOGFIRE_TOKEN

선택 사항 — 생략하면 콘솔 로깅만 사용

HOST, PORT

서버 바인딩 주소


🛠️ 기술 스택

FastAPI · LangChain · LangGraph · Qdrant · Portkey · Sentence-Transformers · Presidio · NeMo Guardrails · RAGAS · MCP Python SDK · Docker


📄 라이선스

MIT — LICENSE 파일 참조.

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    C
    quality
    D
    maintenance
    A Model Context Protocol server that provides Retrieval-Augmented Generation capabilities using Contextual AI, enabling AI interfaces like Cursor IDE and Claude Desktop to query domain-specific knowledge with context-aware responses and source citations.
    1
    21
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables querying enterprise documents (DOCX, PDF, PPTX) using natural language, with hybrid search and MCP integration for Claude Desktop and other agents.
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    An MCP server that enables Claude Desktop to search and read local documents via full-text and fuzzy search, providing direct access to indexed files without chunking.
    MIT

View all related MCP servers

Related MCP Connectors

  • Augments MCP Server - A comprehensive framework documentation provider for Claude Code

  • Query any docs site via MCP. Submit a URL, ask questions, get cited answers.

  • Your memory, everywhere AI goes. Build knowledge once, access it via MCP anywhere.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/imanshrajsingh-boost/mcp-docs-rag-assistant'

If you have feedback or need assistance with the MCP directory API, please join our Discord server