MCP Code Analyzer Setup & Run Instructions
This project demonstrates an MCP (Model Context Protocol) server that integrates an open-source LLM (GPT-J 6B) to analyze a GitHub repository’s code and answer questions about it.
Prerequisites
- Python 3.10 or higher installed on your system.
- Git to clone the repository.
Step 1: Clone the Repository
git clone https://github.com/your-username/your-repo-name.git cd your-repo-name
Step 2: Create and Activate a Virtual Environment
It’s recommended to use a virtual environment for this project:
# Windows: python -m venv venv venv\Scripts\activatemacOS/Linux:
python3 -m venv venv source venv/bin/activate
Step 3: Install Dependencies
Install all required packages using the provided requirements.txt file:
pip install -r requirements.txt
Step 4: Run the MCP Server
In one terminal, start the MCP server:
# Example using the default open-source model: python mcp_server.pyTo use ChatGPT or Claude, set the following environment variables first: LLM_CHOICE=chatgpt # or "claude" OPENAI_API_KEY=your-openai-key # required for ChatGPT ANTHROPIC_API_KEY=your-anthropic-key # required for Claude python mcp_server.py
You should see a message indicating that the server has started (e.g., “Starting MCP server on port 5000...”).
Step 5: Run the MCP Client
Open another terminal (or tab) with the same virtual environment activated, then run:
python mcp_client.py
The client will connect to the server, analyze the GitHub repo, and query the LLM for an answer.
Troubleshooting
- Python Version Errors: Make sure you’re on Python 3.10 or higher.
- Virtual Environment Issues: Double-check that your environment is activated before installing or running.
- LLM Loading Problems: The default CodeLlama model may require significant resources. You can switch models by setting
LLM_CHOICEtochatgptorclaudeif you have the appropriate API keys.
© 2023 Your Name or Organization