Inspiration
What it does
How we built it
Context
Companies move fast and their monorepos and niche libraries are often not part of an agent training data.
When using Agents and AI powered tools to implement new features in large undocumented codebases, codebase exploration sessions end up consuming most of the agent context just to understand which functions exist and how they are used across the repository.
Goal
Keep the main agent free from search tokens so it can focus purely on abstraction and problem solving.
Delegate all codebase and library exploration to sub agents, which return only the minimal information needed such as function names and signatures.
High Level Architecture
Main Agent
- Receives the original user prompt
- Breaks the problem down into logical steps
- For each step, queries the MCP asking which functions can be used
- Operates only on abstractions and function signatures
- Never loads raw repository context or large search results
MCP (Model Context Provider)
Acts as an orchestration layer between the main agent and the codebase.
Responsibilities:
- Receives step level queries from the main agent
- Determines which libraries or repositories are relevant
- Spawns internal sub agents to explore and analyze code
- Returns a curated list of function signatures relevant to the step
MCP Internal Sub Agents
Sub Agent 1: Repository Manager
- Manages a Docker container
- Clones the required repository or library
- Handles environment setup and dependency resolution
- Ensures a clean and reproducible exploration environment
Sub Agent 2: Code Intelligence Agent
- Parses the repository into an Abstract Syntax Tree
- Indexes all relevant nodes
- Generates embeddings for each AST node
- Performs semantic search over the codebase
- Extracts only valuable information based on the main agent query
- Outputs concise function signatures and usage hints
Data Flow
- Main agent receives a task
- Main agent decomposes the task into steps
- For each step, the main agent queries the MCP
- MCP initializes the repository manager if needed
- MCP indexes the codebase using the code intelligence agent
- MCP retrieves relevant functions and signatures
- MCP returns a minimal structured response to the main agent
- Main agent solves the problem using only the provided abstractions
Outcome
This architecture minimizes context usage, reduces noise, and allows the main agent to remain focused on reasoning and design while exploration and retrieval are handled independently and efficiently.
Built With
- anthropic
- groq
- typescript
- xmcp
Log in or sign up for Devpost to join the conversation.