Installation & Setup
Relevant source files
The following files were used as context for generating this wiki page:
DeepCode is an AI Research Engine designed to transform research papers into working code automatically. The installation and setup process involves configuring a Python-based environment, installing dependencies, and setting up the Model Context Protocol (MCP) architecture to enable multi-agent orchestration for code generation and repository management.
Sources: setup.py:76-77, workflows/code_implementation_workflow.py:16-20
Package Installation
The project uses a standard setuptools configuration for installation. It requires Python version 3.9 or higher and relies on external metadata defined in the package's initialization files.
Sources: setup.py:91, setup.py:20-41
Dependencies and Requirements
Project dependencies are managed via a requirements.txt file, which is read during the setup process to populate the install_requires parameter.
Sources: setup.py:44-57, setup.py:100
| Requirement Type | Description | Key Components |
|---|---|---|
| Python Version | Minimum version required | >= 3.9 |
| Core Libraries | Essential for execution | mcp-agent, pyyaml, anthropic, openai |
| Environment | Configuration files | mcp_agent.secrets.yaml, mcp_agent.config.yaml |
Sources: setup.py:91, workflows/code_implementation_workflow.py:27-40
Installation Steps
The following diagram illustrates the package setup and metadata retrieval flow during installation:
The setup process extracts version, author, and URL metadata directly from the source code to ensure consistency across the distribution.
Sources: setup.py:20-57, setup.py:103-107
Environment Configuration
DeepCode requires specific configuration files to manage API keys and agent behavior. These files are typically expected in the project root or specified during workflow initialization.
Sources: workflows/code_implementation_workflow.py:44-48
API and Secret Management
The workflow utilizes a YAML-based configuration system to load secrets and preferred LLM models. The primary configuration file is mcp_agent.secrets.yaml.
Sources: workflows/code_implementation_workflow.py:44, workflows/code_implementation_workflow.py:53-59
| Configuration File | Purpose | Logic |
|---|---|---|
mcp_agent.secrets.yaml | API keys (Anthropic/OpenAI) | Loaded into api_config |
mcp_agent.config.yaml | Default model settings | Parsed via get_default_models |
Sources: workflows/code_implementation_workflow.py:44-46
Workflow Initialization
Setting up the code implementation environment involves initializing MCP agents and defining the workspace where code generation will occur.
Sources: workflows/code_implementation_workflow.py:186-193
MCP Agent Setup
The system connects to specific MCP servers (code-implementation, code-reference-indexer, or command-executor) to perform tasks.
The _initialize_mcp_agent method handles the lifecycle of the agent, ensuring the workspace is correctly set to the generate_code subdirectory of the target project.
Sources: workflows/code_implementation_workflow.py:186-210, workflows/code_implementation_workflow_index.py:186-210
Workspace and Directory Structure
The setup logic checks for the existence of a file tree before starting implementation. If missing, it uses a StructureGeneratorAgent to create the directory hierarchy.
Sources: workflows/code_implementation_workflow.py:75-77, workflows/code_implementation_workflow.py:126-135
The file tree is extracted from the "file_structure" section of the initial reproduction plan provided by the user.
Sources: prompts/code_prompts.py:470-492, workflows/agents/memory_agent_concise.py:133-145
Automated Implementation Setup
Once the environment is installed and the workspace is configured, the system triggers the iterative development loop. This requires the CodeImplementationAgent and ConciseMemoryAgent to be synchronized.
Sources: workflows/code_implementation_workflow.py:161-175
Implementation Logic Components
- LLM Client Initialization: The system attempts to initialize an
AsyncAnthropicorAsyncOpenAIclient by checking keys in the configuration. - Memory Agent Initialization: A
ConciseMemoryAgentis created to track implementation progress and handle memory optimization (clearing history afterwrite_filecalls). - Prompt Injection: System prompts like
PURE_CODE_IMPLEMENTATION_SYSTEM_PROMPTorGENERAL_CODE_IMPLEMENTATION_SYSTEM_PROMPTare loaded to guide the agent's behavior.
Sources: workflows/code_implementation_workflow.py:218-265, workflows/agents/memory_agent_concise.py:59-95, prompts/code_prompts.py:612-680
Conclusion
The installation and setup of DeepCode focus on a modular architecture where the Python environment provides the foundation, and YAML configurations enable the multi-agent MCP workflow. By automating directory creation and secret management, the system prepares a specialized workspace for high-fidelity code reproduction from research papers.
Sources: workflows/code_implementation_workflow.py:21-25, setup.py:76-85