CO

Context Portal RAG Knowledge Graph MCP Server

Enable AI assistants with precise, up-to-date project knowledge using Context Portal's MCP server to build and serve project-specific RAG knowledge graphs.

Overview

Context Portal’s MCP (Model Context Protocol) server provides a standardized way to build, manage, and serve project-specific retrieval-augmented generation (RAG) knowledge graphs to AI assistants. The server ingests project artifacts (documentation, code, tickets, and other knowledge sources), converts them into embedding-backed vector data, and exposes an MCP-compliant API that LLMs or agent frameworks can call to retrieve precise, up-to-date context for generation or decision-making.

By separating context management from model logic, the MCP server helps teams keep knowledge current, enforce source attribution, and reduce hallucinations in assistant responses. It is useful for developer assistants, support bots, and internal search tools that need to combine structured relationships (knowledge graph edges/metadata) with full-text semantic search.

Features

  • Ingest pipelines for common project sources: repo files, docs, tickets, wikis, and exports
  • Embedding-based vector store support (FAISS, Qdrant, Pinecone, etc.)
  • Graph-style metadata and relationship support for fine-grained context signals
  • MCP-compliant HTTP/WebSocket API for retrieval and streaming responses
  • Role-based access and API key / secret configuration
  • Connectors for popular LLM providers (OpenAI, Anthropic, etc.)
  • CLI & dashboard for management, indexing, and monitoring
  • Incremental indexing and change detection to keep context fresh

Installation / Configuration

Prerequisites:

  • Docker (recommended) or Node/Python runtime depending on distribution
  • Vector DB or provider account (Qdrant/Pinecone) and an LLM API key for embeddings

Clone the repo and run with Docker Compose (example):

git clone https://github.com/GreatScottyMac/context-portal.git
cd context-portal
# start server + vector DB (example includes qdrant)
docker-compose up -d

Example docker-compose snippet:

version: "3.8"
services:
  mcp-server:
    image: context-portal/mcp-server:latest
    env_file: .env
    ports:
      - "8080:8080"
    depends_on:
      - qdrant
  qdrant:
    image: qdrant/qdrant:latest
    ports:
      - "6333:6333"

Or run locally (general steps):

# install dependencies (example)
cd context-portal
pip install -r requirements.txt     # or npm install
cp .env.example .env
# edit .env with credentials, endpoints, and keys
./scripts/run-server.sh

Recommended .env variables

VariablePurposeExample
PORTHTTP port for the MCP server8080
DATABASE_URLPrimary metadata DB (Postgres/Mongo)postgres://user:pass@db:5432/context
VECTOR_DB_TYPEWhich vector store to useqdrant, pinecone, faiss
VECTOR_DB_URLVector DB endpointhttp://qdrant:6333
EMBEDDING_API_KEYProvider key for embeddingssk-xxxxx
LLM_PROVIDERLLM API selection for test callsopenai
LLM_API_KEYLLM provider keysk-xxxxx
MCP_SECRETSecret to sign/authorize MCP clientss3cr3t

After configuration, run database migrations (if required) and start the server:

# migrations (example)
./manage migrate
# start
./manage start

Available Tools / Resources

  • Connectors: GitHub, GitLab, local filesystem, Confluence/Notion exports, CSV/JSON imports
  • Vector stores: Qdrant, FAISS, Pinecone (provider-specific modules)
  • LLM adapters: OpenAI, Anthropic, Hugging Face inference endpoints
  • Client SDKs / CLI: lightweight CLI to index content and a JS/Python client for querying
  • Monitoring: built-in metrics endpoints and logs for ingestion / query latencies
  • Dashboard: optional UI to view indexed documents, embeddings, and query traces

API (example usage)

The server exposes MCP-compatible endpoints for retrieval. Example POST to retrieve context:

curl -X POST "http://localhost:8080/mcp/v1/retrieve" \
  -H "Authorization: Bearer ${MCP_SECRET}" \
  -H "Content-Type: application/json" \
  -d '{
    "project_id": "my-project",
    "query": "How does authentication flow work?",
    "top_k": 5
  }'

Example response (abbreviated):

{
  "results": [
    {
      "id": "doc:auth-flow-md",
      "score": 0.97,
      "text": "Authentication uses OAuth2 with JWT tokens ...",
      "metadata": {"source":"docs/auth.md","version":"v1.2"}
    }
  ]
}

Use Cases

  • Developer assistant for codebase onboarding
    Index README, architecture docs, and design RFCs. When a new engineer asks “How do we deploy services?”, the assistant queries the MCP server for the latest deployment docs and returns a concise answer with citations.

  • PR reviewer augmentation
    During CI, the assistant pulls relevant spec sections and previous decisions from the knowledge graph to annotate pull requests with context-aware suggestions and links to related tickets.

  • Customer support knowledge base
    Combine product docs, KB articles, and past support tickets to create a RAG-backed assistant that provides up-to-date, cited answers to customers and suggests escalation paths.

  • Security and compliance audits
    Build a graph of policies, library versions, and audit findings. Query the MCP server for policy texts and artifact provenance when generating audit reports.

Tips for Developers

  • Start small: index a single repo or docs folder to validate the pipeline and tune embedding parameters.
  • Use metadata and relationships: store file paths, authors, timestamps, and explicit edges to improve retrieval precision.
  • Monitor freshness: enable incremental indexing or webhook-driven updates for sources like GitHub to keep the knowledge graph current.
  • Test with multiple LLMs: different models react differently to context length and formatting—benchmark to find the best