Spaces:
Running
Running
File size: 5,893 Bytes
42f1822 df0da5b 42f1822 85057bb 42f1822 6a1e814 150008e 6a1e814 150008e 6a1e814 150008e 6a1e814 150008e 6a1e814 df0da5b 6a1e814 150008e 6a1e814 150008e 6a1e814 150008e 6a1e814 150008e 6a1e814 02bedb7 6a1e814 150008e 6a1e814 150008e 6a1e814 4324a6b 3e57670 0ff2994 4324a6b 3e57670 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
---
title: Defect Solver MCP
emoji: 🛠️
colorFrom: purple
colorTo: yellow
sdk: docker
pinned: false
short_description: Defect Solver - MCP Server
---
# Defect Solver MCP Server
This project implements a Model Context Protocol (MCP) server for defect solver bug localization using FastMCP. It provides multiple bug localization tools that forward bug report data to remote endpoints for prediction and analysis.
## Features
- Exposes three MCP tools for bug localization:
- `multi_module_bug_localization`: Localizes bugs across the entire microservice architecture
- `single_module_bug_localization`: Localizes bugs within a specific module
- `search_space_routing`: Identifies likely microservices (search spaces) for a reported bug
- Forwards issue data (key, summary, description, and optionally module) to configurable remote endpoints
- Returns predicted source code locations and detailed workflow prompts
- Uses async HTTP requests and robust error handling
- Includes workflow and prompt templates for end-to-end bug localization and resolution
## Requirements
- Python >= 3.13
- See `pyproject.toml` for dependencies:
- fastmcp
- httpx
- loguru
- pydantic
- dotenv
- uv
### Note: The tools implemented in this server require a DEFECT SOLVER API KEY to send requests. To get your key, please contact [Lokum AI](https://github.com/lokumai).
## Setup
1. Clone the repository:
```sh
git clone <your-repo-url>
cd defect_solver_mcp_server
```
2. Install dependencies using uv:
```sh
uv sync
```
3. Configure environment variables:
- Copy `.env.example` to `.env` and set the following as needed:
- `DS_API_BASE_URL`
- `DS_API_MULTIMODULE_ENDPOINT`
- `DS_API_SINGLEMODULE_ENDPOINT`
- `DS_API_SEARCHSPACE_ENDPOINT`
- `HF_ACCESS_TOKEN` (optional)
- `TIMEOUT` (optional)
## Usage
Run the MCP server:
```sh
python main.py
```
The server will start and expose the bug localization tools via MCP.
## Available Tools
- **multi_module_bug_localization**: Use when the responsible microservice is unknown. Returns likely microservices and localized files.
- **single_module_bug_localization**: Use when the affected module is known. Returns localized files within the specified module.
- **search_space_routing**: Use to identify the most likely microservices (search spaces) for a reported bug.
## Prompts & Workflow
The server provides prompt templates for:
- Tool selection and workflow planning
- Bug report augmentation
- Bug localization and result explanation
- Automated bug fixing and full resolution workflow
### NOTE: There is a `chatmode.md` file personalized for DNext development that provides detailed instructions and rules on how to use the MCP server with chat-based interactions in IDEs like VSCode, Cursor, Windsurf and etc. Please refer to the [dnext-chatmode.md](https://github.com/pia-team/defect_solver_api/blob/main/.github/chatmodes/dnext-defect-solver.chatmode.md) for more information.
## Configuration
- API base URL and endpoints are configured in `utils/config.py` and via environment variables:
- `DS_API_BASE_URL`, `DS_API_MULTIMODULE_ENDPOINT`, `DS_API_SINGLEMODULE_ENDPOINT`, `DS_API_SEARCHSPACE_ENDPOINT`
- Timeout and HuggingFace access token are also configurable.
-
## MCP Inspector
The MCP Inspector is a tool to help you visualize and debug the interactions with the MCP server.
To use the MCP Inspector, simply run the command below in your terminal:
```sh
npx @modelcontextprotocol/inspector
```
The GUI will open in your default web browser, allowing you to monitor the communication with the MCP server in real-time:
<img src="https://raw.githubusercontent.com/modelcontextprotocol/inspector/main/mcp-inspector.png" alt="MCP Inspector">
## Project Structure
```
main.py # Entry point and MCP server with tool and prompt definitions
utils/config.py # API configuration and environment variable loading
utils/model.py # Pydantic models for request payloads
pyproject.toml # Project metadata and dependencies
README.md # Project documentation
.env.example # Example environment configuration
```
## `mcp.json` Configuration Example for Client Usage
To use this MCP server in a client application that supports MCP, you add the config below to `mcp.json`.
#### PRIVATE MCP SERVER: This config is required for when deploying the MCP server in a private Hugging Face Space that requires authentication.
```json
{
"servers": {
"ds": {
"url": "https://dnext-ds-mcp-server.hf.space/mcp/",
"type": "http",
"headers": {
"DS-API-Key": "${input:defect-solver-api-key}",
"Authorization": "Bearer ${input:hf-access-token}"
}
}
},
"inputs": [
{
"type": "promptString",
"id": "defect-solver-api-key",
"description": "Enter your Defect Solver API Key",
"password": true
},
{
"type": "promptString",
"id": "hf-access-token",
"description": "Enter your Hugging Face Access Token",
"password": true
}
]
}
```
#### PUBLIC MCP SERVER: For public spaces, you can omit the `hf-access-token` input or `Authorization` header.
```json
{
"servers": {
"ds": {
"url": "https://dnext-ds-mcp-server.hf.space/mcp/",
"type": "http",
"headers": {
"DS-API-Key": "${input:defect-solver-api-key}"
}
}
},
"inputs": [
{
"type": "promptString",
"id": "defect-solver-api-key",
"description": "Enter your Defect Solver API Key",
"password": true
}
]
}
``` |