Cortex is an advanced AI Agent Orchestrator built on the Model Context Protocol (MCP). It uses a split-architecture design where a central "Brain" (Orchestrator) communicates with a local "Tool Server" via standard input/output (stdio), allowing for secure, modular, and extensible tool usage.
It features a premium, ChatGPT-style UI with real-time streaming, collapsible "Chain of Thought" reasoning logs, and Markdown rendering.
- β‘ Model Context Protocol (MCP): Decouples the LLM from the tools using a standardized server-client architecture.
- π€ LangGraph Orchestration: Uses a ReAct (Reason + Act) agent loop to plan, execute, and refine answers.
- π§ Advanced RAG: Built-in "Memory" using ChromaDB and HuggingFace Embeddings (
all-MiniLM-L6-v2) to ingest and recall information from URLs. - π Real-Time Streaming: Full token-by-token streaming from the backend to the React UI.
- π‘οΈ Robust Windows Support: Custom
launcher.pyarchitecture to handlestdiopipes and event loops correctly on Windows. - π¨ Modern UI: Dark-themed React interface with "Chain of Thought" accordions, typing indicators, and auto-scrolling.
graph LR
A[React Frontend] <-->|"Stream API"| B[FastAPI Orchestrator]
B <-->|"Stdio Pipe (MCP)"| C[Launcher Script]
C <-->|"Subprocess (Stderr Log)"| D[MCP Tool Server]
D <-->|"Search/RAG"| E[External APIs & ChromaDB]
- Backend: Python, FastAPI, LangChain, LangGraph,
mcp(Python SDK), ChromaDB. - LLM Provider: Groq (Llama-3-70b).
- Frontend: React (Vite), CSS Modules (No Tailwind dependency), Lucide Icons, React Markdown.
- Observability: Langfuse (Optional, for tracing).
- Python 3.10+
- Node.js & npm
- A Groq API Key (Get one here)
- A SerpApi Key (For Google Search)
-
Clone the repository and navigate to the backend folder:
cd backend -
Create a Virtual Environment:
python -m venv venv # Windows venv\Scripts\activate # Mac/Linux source venv/bin/activate
-
Install Dependencies:
pip install fastapi uvicorn mcp langchain-groq langgraph langchain-community langchain-chroma langchain-huggingface sentence-transformers python-dotenv langfuse
-
Configure Environment: Create a
.envfile in thebackendfolder:GROQ_API_KEY=gsk_your_key_here SERPAPI_API_KEY=your_serpapi_key # Optional: Langfuse for tracing LANGFUSE_PUBLIC_KEY=pk-lf-... LANGFUSE_SECRET_KEY=sk-lf-... LANGFUSE_HOST=https://cloud.langfuse.com
-
Navigate to the frontend folder:
cd ../frontend -
Install Node Modules:
npm install npm install lucide-react react-markdown remark-gfm
-
Configure Environment: Create a
.envfile in thefrontendroot:VITE_API_URL=http://localhost:8002/api/chat
The Orchestrator will automatically manage the Tool Server process.
# In the backend/ folder (with venv activated)
python orchestrator.pyYou should see: Uvicorn running on http://0.0.0.0:8002
# In the frontend/ folder
npm run devOpen your browser to http://localhost:5173
/project-root
βββ /backend
β βββ orchestrator.py # Main API & Agent Logic
β βββ launcher.py # Windows Pipe Handler (CRITICAL)
β βββ server.py # MCP Tool Server (Weather, RAG, Search)
β βββ .env # API Keys
β βββ chroma_db_mcp/ # Vector Database Storage
β
βββ /frontend
β βββ src/
β β βββ ChatInterface.jsx # Main Chat Component
β β βββ ChatInterface.css # Styles & Animations
β β βββ App.jsx # App Entry
β β βββ main.jsx # React Root (Strict Mode disabled)
β βββ .env # Frontend Config
β βββ package.json
β
βββ README.md
1. CRITICAL ERROR: Orchestrator Error: unhandled errors in a TaskGroup
- Cause: The MCP Server crashed on startup, usually due to a missing library or API key.
- Fix: Check the
backend/server_debug.logfile generated by thelauncher.py. It will show the exact error (e.g.,ModuleNotFoundError).
2. "Double Text" Glitch (e.g., "The weather isThe weather is...")
- Cause: React Strict Mode runs effects twice in development.
- Fix: Ensure
main.jsxdoes not have<StrictMode>wrapping the<App />.
3. Connection Closed Error
- Cause:
print()statements inserver.pycorrupting the JSON stream. - Fix: Use the
launcher.pyscript (already integrated), which redirects all unexpected output to stderr/log files.
- RAG: "Ingest https://example.com/article. After learning it, tell me the main summary."
- Complex Logic: "Find the birth city of the current CEO of Microsoft, check the weather there, and tell me a fun fact about that city."
- Reasoning: "I have a Python recursion error. Explain why it happens and write code to fix it."
Distributed under the MIT License. See LICENSE for more information.


