Abid Ali Awan
commited on
Commit
·
d1e576c
1
Parent(s):
a91847b
Enhance README with detailed local setup instructions, clarify integration with MCP clients, and update code quality score description. Remove outdated sections and improve formatting for better readability.
Browse files- README.md +53 -42
- requirements.txt +0 -1
- src/app.py +2 -5
README.md
CHANGED
@@ -16,48 +16,10 @@ short_description: Generate quality metrics and a detailed report for your code
|
|
16 |
|
17 |
This project is a Gradio-based MCP server that provides two code analysis functionalities:
|
18 |
|
19 |
-
- **Code Quality Score**: Provides an averaged score across vulnerability, style, and quality for the provided code using top three AI providers.
|
20 |
- **Code Analysis Report**: Generates a detailed report about the provided code, including basic information and suggesting 5-10 potential fixes to improve the code.
|
21 |
|
22 |
-
##
|
23 |
-
|
24 |
-
1. Clone the repository.
|
25 |
-
2. Navigate to the project directory.
|
26 |
-
3. Install the required dependencies:
|
27 |
-
|
28 |
-
```bash
|
29 |
-
pip install -r requirements.txt
|
30 |
-
```
|
31 |
-
|
32 |
-
4. Run the application:
|
33 |
-
|
34 |
-
```bash
|
35 |
-
python src/app.py
|
36 |
-
```
|
37 |
-
|
38 |
-
5. The Gradio interface will be available at `http://127.0.0.1:7860/` and MCP server will be avaible at `http://127.0.0.1:7860/gradio_api/mcp/sse`.
|
39 |
-
|
40 |
-
## Connecting to Cursor AI
|
41 |
-
|
42 |
-
7. 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.
|
43 |
-
|
44 |
-
8. Add the following JSON configuration to the MCP settings file:
|
45 |
-
```json
|
46 |
-
{
|
47 |
-
"mcpServers": {
|
48 |
-
"gradio": {
|
49 |
-
"url": "http://127.0.0.1:7860/gradio_api/mcp/sse"
|
50 |
-
}
|
51 |
-
}
|
52 |
-
}
|
53 |
-
```
|
54 |
-
|
55 |
-
9. Save the file. You will now see an active MCP server named `gradio` with the tools `code_analysis_report` and `code_analysis_score`.
|
56 |
-
|
57 |
-
|
58 |
-
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.
|
59 |
-
|
60 |
-
### Integration with other clients
|
61 |
|
62 |
For clients that support SSE (e.g. Cursor, Windsurf, Cline), simply add the following configuration to your MCP config:
|
63 |
|
@@ -71,7 +33,7 @@ For clients that support SSE (e.g. Cursor, Windsurf, Cline), simply add the foll
|
|
71 |
}
|
72 |
```
|
73 |
|
74 |
-
For clients that
|
75 |
|
76 |
```json
|
77 |
{
|
@@ -89,7 +51,7 @@ For clients that only support stdio, first install Node.js. Then, you can use th
|
|
89 |
}
|
90 |
```
|
91 |
|
92 |
-
|
93 |
|
94 |
Here are a few ways you can ask Cursor AI to use these tools:
|
95 |
|
@@ -98,4 +60,53 @@ Here are a few ways you can ask Cursor AI to use these tools:
|
|
98 |
* "Analyze this code and tell me how to fix the top issues."
|
99 |
* "What is the quality score of this code?"
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
|
|
16 |
|
17 |
This project is a Gradio-based MCP server that provides two code analysis functionalities:
|
18 |
|
19 |
+
- **Code Quality Score**: Provides an averaged score across vulnerability, style, and quality for the provided code using top three AI providers (OpenAI, Anthropic, Mistral).
|
20 |
- **Code Analysis Report**: Generates a detailed report about the provided code, including basic information and suggesting 5-10 potential fixes to improve the code.
|
21 |
|
22 |
+
## Integration with MCP clients
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
For clients that support SSE (e.g. Cursor, Windsurf, Cline), simply add the following configuration to your MCP config:
|
25 |
|
|
|
33 |
}
|
34 |
```
|
35 |
|
36 |
+
For clients that dose not support SSE, first install Node.js. Then, you can use the following command:
|
37 |
|
38 |
```json
|
39 |
{
|
|
|
51 |
}
|
52 |
```
|
53 |
|
54 |
+
## Sample Prompts
|
55 |
|
56 |
Here are a few ways you can ask Cursor AI to use these tools:
|
57 |
|
|
|
60 |
* "Analyze this code and tell me how to fix the top issues."
|
61 |
* "What is the quality score of this code?"
|
62 |
|
63 |
+
## Local Setup and Running
|
64 |
+
|
65 |
+
1. Clone the repository.
|
66 |
+
2. Navigate to the project directory.
|
67 |
+
3. Install the required dependencies:
|
68 |
+
|
69 |
+
```bash
|
70 |
+
pip install -r requirements.txt
|
71 |
+
```
|
72 |
+
|
73 |
+
4. Set up the required environment variables for the API keys:
|
74 |
+
|
75 |
+
```bash
|
76 |
+
export OPENAI_API_KEY=your_openai_api_key
|
77 |
+
export ANTHROPIC_API_KEY=your_anthropic_api_key
|
78 |
+
export MISTRAL_API_KEY=your_mistral_api_key
|
79 |
+
```
|
80 |
+
|
81 |
+
Replace `your_openai_api_key`, `your_anthropic_api_key`, and `your_mistral_api_key` with your actual API keys.
|
82 |
+
|
83 |
+
5. Run the application:
|
84 |
+
|
85 |
+
```bash
|
86 |
+
python src/app.py
|
87 |
+
```
|
88 |
+
|
89 |
+
6. The Gradio interface will be available at `http://127.0.0.1:7860/` and MCP server will be avaible at `http://127.0.0.1:7860/gradio_api/mcp/sse`.
|
90 |
+
|
91 |
+
## Connecting to Cursor AI
|
92 |
+
|
93 |
+
7. 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.
|
94 |
+
|
95 |
+
8. Add the following JSON configuration to the MCP settings file:
|
96 |
+
```json
|
97 |
+
{
|
98 |
+
"mcpServers": {
|
99 |
+
"gradio": {
|
100 |
+
"url": "http://127.0.0.1:7860/gradio_api/mcp/sse"
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
```
|
105 |
+
|
106 |
+
9. Save the file. You will now see an active MCP server named `gradio` with the tools `code_analysis_report` and `code_analysis_score`.
|
107 |
+
|
108 |
+
|
109 |
+
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.
|
110 |
+
|
111 |
+
|
112 |
|
requirements.txt
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
python-dotenv>=1.1.0
|
2 |
mistralai==1.8.1
|
3 |
openai==1.84.0
|
4 |
anthropic==0.52.2
|
|
|
|
|
1 |
mistralai==1.8.1
|
2 |
openai==1.84.0
|
3 |
anthropic==0.52.2
|
src/app.py
CHANGED
@@ -1,11 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
-
from dotenv import load_dotenv
|
3 |
|
4 |
from code_analyzer.analysis import code_analysis_report
|
5 |
from code_analyzer.scoring import code_analysis_score
|
6 |
|
7 |
-
load_dotenv()
|
8 |
-
|
9 |
|
10 |
# Create Gradio interfaces for code analysis
|
11 |
analysis_report_demo = gr.Interface(
|
@@ -25,8 +22,8 @@ code_score_demo = gr.Interface(
|
|
25 |
# Create tabbed interface
|
26 |
demo = gr.TabbedInterface(
|
27 |
[analysis_report_demo, code_score_demo],
|
28 |
-
["🧐Code Analysis", "
|
29 |
-
title="
|
30 |
theme=gr.themes.Soft(),
|
31 |
)
|
32 |
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
from code_analyzer.analysis import code_analysis_report
|
4 |
from code_analyzer.scoring import code_analysis_score
|
5 |
|
|
|
|
|
6 |
|
7 |
# Create Gradio interfaces for code analysis
|
8 |
analysis_report_demo = gr.Interface(
|
|
|
22 |
# Create tabbed interface
|
23 |
demo = gr.TabbedInterface(
|
24 |
[analysis_report_demo, code_score_demo],
|
25 |
+
["🧐Code Analysis", "🥇Code Score"],
|
26 |
+
title="Code Scoring & Analysis MCP Server",
|
27 |
theme=gr.themes.Soft(),
|
28 |
)
|
29 |
|