Production-grade, multi-tenant SaaS platform that orchestrates cross-service workflows through an Agentic MCP (Model Context Protocol) Gateway.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FRONTEND β Next.js 14 β
β DAG Editor Β· HITL Modal Β· Live Preview Β· Chat Β· State Graph β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β REST + SSE
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API GATEWAY β FastAPI β
β Firebase Auth Β· Rate Limit Β· Tenant Isolation Β· Audit β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LANGGRAPH AGENT PIPELINE β
β Classifier β Planner β Critic β HITL Gate β Executor β β
β Monitor β Synthesizer Β· RAG Retriever Β· RAG Responder β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MCP-GUARD SECURITY PROXY β
β SHA-256 hash Β· injection scan Β· param enforce Β· approval gate β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CUSTOM MCP SERVER β JSON-RPC 2.0 (stdio / SSE) β
β GitHub (7) Β· Slack (3) Β· Sheets (3) Β· Trello (6) tools β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Feature | Description |
|---|---|
| Custom MCP Server | JSON-RPC 2.0 protocol from scratch β 19 tools across 4 services |
| LangGraph State Machine | 10-node graph with conditional routing, parallel execution |
| HITL DAG Editing | Pause, edit nodes/edges, resume from dirty set (no restart) |
| Live Platform Previews | SSE-streamed UI previews before tool execution |
| RAG Chatbot | ChromaDB vector search over executions, context-aware responses |
| Concurrency Runtime | Celery + Redis for 5+ simultaneous tenant workflows |
| Code Analysis | 18 languages, 6 categories (bug, security, perf, quality, arch, CI/CD) |
| State Graph Visualization | Full LangGraph topology with active node overlays |
kontexo-v2/
βββ kontexo_mcp_server/ # Custom MCP server (Phase 1)
β βββ protocol.py # JSON-RPC 2.0 types + codec
β βββ server.py # MCP request router
β βββ registry.py # Tool/resource/prompt registry
β βββ client.py # MCP client for remote servers
β βββ transport/ # stdio + SSE transports
β βββ tools/ # GitHub, Slack, Sheets, Trello tools
β βββ resources/ # MCP resource providers
β βββ prompts/ # MCP prompt templates
β
βββ backend/
β βββ app/
β β βββ agents/ # LangGraph nodes (Phase 2)
β β β βββ state.py # KontexoState TypedDict (33+ fields)
β β β βββ graph.py # 10-node state machine
β β β βββ code_analyzer.py # Multi-category static + LLM analysis
β β β βββ fix_proposer.py # PR/issue/Slack/Sheets proposals
β β β βββ language_detector.py # 18-language detection
β β β
β β βββ concurrency/ # Celery + Redis (Phase 3)
β β β βββ celery_app.py # Celery config (Redis broker)
β β β βββ redis_conn.py # Sync + async Redis with pooling
β β β βββ rate_limiter.py # Per-tenant rate limiting
β β β βββ sse_manager.py # Redis pub/sub β SSE fan-out
β β β βββ tasks.py # Async workflow/node tasks
β β β
β β βββ rag/ # RAG engine (Phase 4)
β β β βββ embedder.py # ChromaDB client + tenant collections
β β β βββ retriever.py # Vector similarity search
β β β βββ indexer.py # Document indexing pipeline
β β β
β β βββ mcp/ # MCP integration (Phase 5)
β β β βββ guard.py # MCPGuard approval gating
β β β βββ preview_emitter.py # PreviewEvent + service builders
β β β
β β βββ routers/ # FastAPI endpoints (Phase 6-8)
β β β βββ executions.py # HITL edit + DAG introspection
β β β βββ chat.py # RAG chatbot
β β β βββ code_analysis.py # Code analysis endpoints
β β β βββ state_graph.py # State graph visualization
β β β
β β βββ llm/ # LLM router
β β β βββ router.py # Gemini Flash β Groq failover
β β β
β β βββ models/ # Pydantic models
β β βββ dag.py # DAG, Node, Edge, AnalysisFinding
β β
β βββ tests/ # 618 tests
β
βββ docker-compose.yml # Redis, Celery, Chroma, Backend, MCP
βββ .env.example # All environment variables
βββ README.md
| Layer | Technology |
|---|---|
| Backend | Python 3.13, FastAPI, Pydantic 2 |
| Agent Framework | LangGraph 1.1, LangChain Core 1.2 |
| LLM | Gemini Flash (primary, env-configurable) β Groq (failover, key rotation) |
| Task Queue | Celery 5.6 + Redis 7 |
| Vector Store | ChromaDB 1.5 (all-MiniLM-L6-v2 embeddings) |
| Graph Library | NetworkX 3.6 (DAG validation, cycle detection) |
| HTTP Client | httpx 0.28 (async, 30s/120s timeouts) |
| Frontend | Next.js 14, React 18, ReactFlow 11, Zustand, Firebase JS SDK, Tailwind CSS |
| Auth | Firebase Auth (Google + GitHub OAuth via signInWithPopup) |
| Protocol | JSON-RPC 2.0 (custom implementation, no SDK) |
- Python 3.12+
- Docker & Docker Compose
- Redis (or use Docker)
# Clone and setup
cd kontexo-v2
python -m venv venv
source venv/bin/activate
pip install -r backend/requirements.txt
# Configure environment
cp .env.example .env
# Edit .env with your API keys (GEMINI_API_KEY required)
# Start Redis (if not using Docker)
redis-server &
# Run tests
python -m pytest backend/tests/ kontexo_mcp_server/tests/ -v
# Start backend
uvicorn backend.app.main:app --host 0.0.0.0 --port 8080 --reload
# Start Celery worker (separate terminal)
celery -A backend.app.concurrency.celery_app worker --loglevel=info --queues=default,workflows
# Start frontend (separate terminal)
cd frontend && npm install && npm run dev
# Frontend: http://localhost:3000
# Login via Google or GitHub on the frontendcp .env.example .env
# Edit .env with API keys
docker compose up -d
# Services:
# Backend: http://localhost:8080
# MCP SSE: http://localhost:8090
# Redis: localhost:6379
# ChromaDB: http://localhost:8000Custom JSON-RPC 2.0 implementation with 19 tools:
| Service | Tools | Approval Required |
|---|---|---|
| GitHub | create_issue, create_pull_request, add_comment, list_issues, get_issue, list_repos, search_code | Write ops: Yes |
| Slack | send_message, list_channels, get_channel_history | send_message: Yes |
| Google Sheets | append_row, read_range, create_spreadsheet | Write ops: Yes |
| Trello | create_card, move_card, add_checklist, list_boards, list_cards, archive_card | Write ops: Yes |
Transports: stdio (local) or SSE (remote HTTP)
10-node state machine with conditional routing:
ββββββββββββββββ
β classifier β
ββββββββ¬ββββββββ
ββββββββ΄ββββββββ
βββββββ€ planner βββββββ
β ββββββββββββββββ β
βΌ βΌ
ββββββββββββββ βββββββββββββββββ
β critic β β rag_retriever β
ββββββββ¬ββββββ βββββββββ¬ββββββββ
β βΌ
ββββββββ΄ββββββ βββββββββββββββββ
β replanner β β rag_responder β
ββββββββ¬ββββββ βββββββββββββββββ
βΌ
ββββββββββββββ
β hitl_gate β
ββββββββ¬ββββββ
βΌ
ββββββββββββββ
β executor β
ββββββββ¬ββββββ
βΌ
ββββββββββββββ
β monitor β
ββββββββ¬ββββββ
βΌ
βββββββββββββββ
β synthesizer β
βββββββββββββββ
Supports 18 programming languages across 6 analysis categories:
Languages: Python, JavaScript, TypeScript, Java, Go, Rust, C, C++, C#, PHP, Ruby, Kotlin, Swift, SQL, Bash, YAML, Dockerfile, Terraform
Categories:
- Bug Detection β Logic errors, null risks, async misuse
- Security β OWASP Top 10, hardcoded secrets, injection vulnerabilities
- Performance β N+1 queries, O(nΒ²) patterns, SELECT *
- Code Quality β Dead code, deep nesting, TODO annotations
- Architecture β Circular deps, tight coupling, SOLID violations
- CI/CD β Dockerfile best practices, GitHub Actions security, Terraform
18 built-in static patterns + LLM-powered deep analysis.
- Celery workers with Redis broker for async workflow execution
- Per-tenant rate limiting (10 concurrent, 100/hour, 5 LLM calls)
- Redis pub/sub β SSE fan-out for real-time event streaming
- Distributed locks prevent concurrent execution of same workflow
- Tested with 5 simultaneous users without errors
# Run all tests (618 tests across 9 phases)
python -m pytest backend/tests/ kontexo_mcp_server/tests/ -v
# Phase-specific
python -m pytest backend/tests/test_phase2.py -v # LangGraph
python -m pytest backend/tests/test_concurrency.py -v # Concurrency
python -m pytest backend/tests/test_phase8.py -v # Code Analysis
python -m pytest kontexo_mcp_server/tests/ -v # MCP Protocol
# Performance benchmark
python -m pytest backend/tests/test_phase9_benchmark.py -vFirebase Auth on all /api/* routes. Public endpoint: /health.
Frontend: Users sign in via Google or GitHub popup (signInWithPopup). The Firebase JS SDK manages the session and provides ID tokens automatically.
Backend: The FastAPI get_current_user dependency verifies Firebase ID tokens using the Firebase Admin SDK. Custom claims role and tenant_id can be set via Firebase Admin.
# Get current user info (requires Firebase ID token)
curl -H "Authorization: Bearer <firebase-id-token>" http://localhost:8080/auth/me
# All /api/* routes require the same Bearer token
curl -H "Authorization: Bearer <firebase-id-token>" http://localhost:8080/api/state-graph| Variable | Required | Default | Description |
|---|---|---|---|
FIREBASE_SERVICE_ACCOUNT_PATH |
Yes | service-account.json |
Path to Firebase Admin SDK service account JSON |
GEMINI_API_KEY |
Yes | β | Google Gemini Flash API key |
GEMINI_FLASH_MODEL |
No | gemini-2.5-flash |
Gemini model name |
GROQ_API_KEYS |
No | β | JSON array of Groq API keys (round-robin rotation) |
GROQ_MODEL |
No | llama-3.1-70b-versatile |
Groq model name |
CORS_ORIGINS |
No | ["*"] |
JSON array of allowed CORS origins |
REDIS_URL |
No | redis://localhost:6379/0 |
Redis connection URL |
CHROMA_PERSIST_DIR |
No | β (in-memory) | ChromaDB persistence path |
GITHUB_TOKEN |
No | β | GitHub personal access token |
SLACK_BOT_TOKEN |
No | β | Slack Bot OAuth token |
TRELLO_API_KEY |
No | β | Trello API key |
TRELLO_TOKEN |
No | β | Trello auth token |
GOOGLE_SHEETS_ACCESS_TOKEN |
No | β | Google Sheets OAuth token |
GOOGLE_SHEETS_CREDENTIALS_JSON |
No | β | Sheets service account JSON |
LLM_CACHE_TTL |
No | 3600 |
LLM response cache TTL in seconds |
| Phase | Description | Tests |
|---|---|---|
| 1 | Custom MCP Server (JSON-RPC 2.0) | 81 |
| 2 | LangGraph State Machine (10 nodes) | 79 |
| 3 | Concurrency Infrastructure (Celery + Redis) | 33 |
| 4 | RAG-Powered Chatbot (ChromaDB) | 43 |
| 5 | Live Platform Previews (SSE) | 62 |
| 6 | Frontend DAG Editor (backend) | 56 |
| 7 | State Graph Visualization | 50 |
| 8 | Code Analysis (18 langs, 6 categories) | 204 |
| 9 | Integration & Polish | 10 |
| 10 | Frontend + Auth + Wiring | β |
| Total | 618 |
14 pages built with Next.js 14, React 18, ReactFlow 11, Zustand, and Tailwind CSS:
| Page | Path | Description |
|---|---|---|
| Landing | / |
Marketing page with feature highlights |
| Login | /login |
Firebase Auth β Google + GitHub sign-in |
| Overview | /overview |
Dashboard with health check + system status |
| Analytics | /analytics |
Real-time metrics and charts |
| Workflows | /workflows |
DAG Editor (ReactFlow) with Generate DAG β backend |
| Executions | /executions |
Real-time execution list (Redis-backed) |
| Chat | /chat |
RAG chatbot with SSE streaming |
| Code Analysis | /code-analysis |
Monaco editor + findings list + heatmap |
| State Graph | /state-graph |
LangGraph topology visualization |
| Connections | /connections |
Service integration management |
| Settings | /settings |
Profile, API config, workspace settings |
Proprietary β All rights reserved.