A newer version of the Gradio SDK is available:
5.35.0
title: Code Analysis MCP
emoji: π©βπ»
colorFrom: gray
colorTo: yellow
sdk: gradio
sdk_version: 5.33.0
app_file: src/app.py
tags:
- mcp-server-track
- code-analysis
- openai
- anthropic
- mistral
pinned: false
license: apache-2.0
short_description: Generate quality metrics and a detailed report for your code
Code Analysis MCP Server
This project is a Gradio-based MCP server that provides two code analysis functionalities:
Code Quality Score: Provides an averaged score across vulnerability, style, and quality for the provided code using top three AI providers (OpenAI, Anthropic, Mistral).
- Vulnerability Score: Measures the likelihood of the code containing vulnerabilities.
- Style Score: Measures the adherence to coding style guidelines.
- Quality Score: Measures the overall quality of the code.
Code Analysis Report: Generates a detailed report using Claude Sonnet 4, providing insights about the provided code, including basic information and suggesting 5-10 potential fixes to improve the code.
Video & Demo
Gradio App URL: https://agents-mcp-hackathon-code-analysis-mcp.hf.space
MCP Server URL: https://agents-mcp-hackathon-code-analysis-mcp.hf.space/gradio_api/mcp/sse
Watch the demo video: Code Analysis MCP Demo (Agents MCP Hackathon)
Integration with MCP clients
For clients that support SSE (e.g. Cursor, Windsurf, Cline), simply add the following configuration to your MCP config:
{
"mcpServers": {
"gradio": {
"url": "https://agents-mcp-hackathon-code-analysis-mcp.hf.space/gradio_api/mcp/sse"
}
}
}
For clients that dose not support SSE, first install Node.js. Then, you can use the following command:
{
"mcpServers": {
"gradio": {
"command": "npx",
"args": [
"mcp-remote",
"https://agents-mcp-hackathon-code-analysis-mcp.hf.space/gradio_api/mcp/sse",
"--transport",
"sse-only"
]
}
}
}
Sample Prompts
Here are a few ways you can ask Cursor AI to use these tools:
- "Can you give me a code quality score for this Python snippet?"
- "Generate a code analysis report for the following JavaScript code."
- "Analyze this code and tell me how to fix the top issues."
- "What is the quality score of this code?"
Local Setup and Running
Clone the repository.
Navigate to the project directory.
Install the required dependencies:
pip install -r requirements.txt
Set up the required environment variables for the API keys:
export OPENAI_API_KEY=your_openai_api_key export ANTHROPIC_API_KEY=your_anthropic_api_key export MISTRAL_API_KEY=your_mistral_api_key
Replace
your_openai_api_key
,your_anthropic_api_key
, andyour_mistral_api_key
with your actual API keys.Run the application:
python src/app.py
The Gradio interface will be available at
http://127.0.0.1:7860/
and MCP server will be avaible athttp://127.0.0.1:7860/gradio_api/mcp/sse
.
Connecting to Cursor AI
To test the MCP server with Cursor AI, open Cursor Settings, navigate to the "MCP" tab, and click the "+ Add new global MCP server" button.
Add the following JSON configuration to the MCP settings file:
{
"mcpServers": {
"gradio": {
"url": "http://127.0.0.1:7860/gradio_api/mcp/sse"
}
}
}
- Save the file. You will now see an active MCP server named
gradio
with the toolscode_analysis_report
andcode_analysis_score
.
To test this MCP server, you can create a new chat in agent mode of the Cursor using (CTRL +T) and ask for a code analysis report (e.g., "analyze this Python code: print('hello')"). Cursor will ask for permission to run the MCP tool. Approve it.