testhub-mcp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,75 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ /lib/
14
+ /lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual environments
24
+ venv/
25
+ ENV/
26
+ env/
27
+ .venv/
28
+
29
+ # IDE
30
+ .idea/
31
+ .vscode/
32
+ *.swp
33
+ *.swo
34
+ *~
35
+
36
+ # Logs
37
+ *.log
38
+ logs/
39
+
40
+ # Database
41
+ *.db
42
+ *.sqlite3
43
+
44
+ # Environment variables
45
+ .env
46
+ .env.local
47
+ .env.*.local
48
+
49
+ # Node.js
50
+ node_modules/
51
+ npm-debug.log*
52
+ yarn-debug.log*
53
+ yarn-error.log*
54
+
55
+ # Build output
56
+ frontend/dist/
57
+ frontend/build/
58
+
59
+ # OS
60
+ .DS_Store
61
+ Thumbs.db
62
+
63
+ # Test coverage
64
+ htmlcov/
65
+ .coverage
66
+ .coverage.*
67
+ coverage.xml
68
+ *.cover
69
+
70
+ # Pytest
71
+ .pytest_cache/
72
+
73
+ # mypy
74
+ .mypy_cache/
75
+
@@ -0,0 +1,330 @@
1
+ Metadata-Version: 2.4
2
+ Name: testhub-mcp
3
+ Version: 0.1.0
4
+ Summary: TestHub MCP Server - 提供开发任务管理和项目文档集成
5
+ Author: TestHub Team
6
+ License: MIT
7
+ Keywords: cursor,documentation,mcp,testhub
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Python: >=3.10
16
+ Requires-Dist: httpx>=0.25.0
17
+ Requires-Dist: loguru>=0.7.0
18
+ Requires-Dist: mcp>=1.0.0
19
+ Provides-Extra: all
20
+ Requires-Dist: black>=23.0.0; extra == 'all'
21
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'all'
22
+ Requires-Dist: pytest>=7.0.0; extra == 'all'
23
+ Requires-Dist: ruff>=0.1.0; extra == 'all'
24
+ Requires-Dist: sse-starlette>=1.6.0; extra == 'all'
25
+ Requires-Dist: starlette>=0.27.0; extra == 'all'
26
+ Requires-Dist: uvicorn>=0.23.0; extra == 'all'
27
+ Provides-Extra: dev
28
+ Requires-Dist: black>=23.0.0; extra == 'dev'
29
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
30
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
31
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
32
+ Provides-Extra: sse
33
+ Requires-Dist: sse-starlette>=1.6.0; extra == 'sse'
34
+ Requires-Dist: starlette>=0.27.0; extra == 'sse'
35
+ Requires-Dist: uvicorn>=0.23.0; extra == 'sse'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # TestHub MCP Server
39
+
40
+ TestHub MCP Server 是一个 [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) 服务器,用于在 Cursor IDE 中集成 TestHub 开发管理系统。通过 MCP 协议,AI 助手可以直接与 TestHub 交互,实现任务管理、评审文档生成、会话同步等功能。
41
+
42
+ ## 功能特性
43
+
44
+ - 📋 **任务管理**:获取任务详情、更新状态、查看待办列表
45
+ - 📝 **评审文档**:自动生成设计文档、代码评审文档
46
+ - 💾 **会话同步**:记录开发会话、关键决策、修改文件
47
+ - 🐛 **Bug 管理**:快速创建 Bug 报告
48
+ - 📚 **文档访问**:访问项目文档资源
49
+
50
+ ## 快速开始
51
+
52
+ ### 前置要求
53
+
54
+ - Python >= 3.10
55
+ - Cursor IDE
56
+ - TestHub 后端服务运行中
57
+
58
+ ### 安装方式
59
+
60
+ #### 方式一:使用 uvx(推荐)
61
+
62
+ 无需单独安装,直接在 Cursor 配置中使用:
63
+
64
+ ```json
65
+ {
66
+ "mcpServers": {
67
+ "testhub": {
68
+ "command": "uvx",
69
+ "args": ["--from", "path/to/testhub_mcp", "testhub-mcp"],
70
+ "env": {
71
+ "TESTHUB_API_URL": "https://testhub.yourcompany.com/api/v1",
72
+ "TESTHUB_API_TOKEN": "your-personal-api-token",
73
+ "TESTHUB_TEAM_ID": "2",
74
+ "TESTHUB_SESSION_ID": "15"
75
+ }
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ #### 方式二:使用 pip 安装
82
+
83
+ ```bash
84
+ # 进入 testhub_mcp 目录
85
+ cd testhub_mcp
86
+
87
+ # 安装到当前环境
88
+ pip install -e .
89
+
90
+ # 或使用 uv
91
+ uv pip install -e .
92
+ ```
93
+
94
+ ### 配置 Cursor
95
+
96
+ 1. 创建或编辑 Cursor MCP 配置文件:
97
+
98
+ **全局配置**(适用于所有项目):
99
+ ```
100
+ ~/.cursor/mcp.json
101
+ ```
102
+
103
+ **项目配置**(仅适用于当前项目):
104
+ ```
105
+ 项目根目录/.cursor/mcp.json
106
+ ```
107
+
108
+ 2. 添加以下配置:
109
+
110
+ ```json
111
+ {
112
+ "mcpServers": {
113
+ "testhub": {
114
+ "command": "testhub-mcp",
115
+ "env": {
116
+ "TESTHUB_API_URL": "https://testhub.yourcompany.com/api/v1",
117
+ "TESTHUB_API_TOKEN": "your-personal-api-token",
118
+ "TESTHUB_TEAM_ID": "2",
119
+ "TESTHUB_SESSION_ID": "15"
120
+ }
121
+ }
122
+ }
123
+ }
124
+ ```
125
+
126
+ ### 配置 Cursor Rules
127
+
128
+ 将 `cursor_rules/testhub-integration.mdc` 文件复制到项目的 `.cursor/rules/` 目录:
129
+
130
+ ```bash
131
+ mkdir -p .cursor/rules
132
+ cp cursor_rules/testhub-integration.mdc .cursor/rules/
133
+ ```
134
+
135
+ 或者手动创建符号链接(推荐,便于更新):
136
+
137
+ ```bash
138
+ mkdir -p .cursor/rules
139
+ ln -s ../../cursor_rules/testhub-integration.mdc .cursor/rules/testhub-integration.mdc
140
+ ```
141
+
142
+ ### 环境变量
143
+
144
+ | 变量名 | 必填 | 说明 | 示例 |
145
+ |-------|------|------|------|
146
+ | `TESTHUB_API_URL` | ✅ | TestHub API 地址 | `https://testhub.yourcompany.com/api/v1` |
147
+ | `TESTHUB_API_TOKEN` | ✅ | 个人 API Token | `th_xxx_xxxxx` |
148
+ | `TESTHUB_TEAM_ID` | ✅ | 团队 ID | `2` |
149
+ | `TESTHUB_SESSION_ID` | ⚠️ 推荐 | 默认开发会话 ID,创建任务时自动关联 | `15` |
150
+ | `PROJECT_DOCS_PATH` | ⬜ | 项目文档路径 | `./docs` |
151
+
152
+ > **💡 提示**:`TESTHUB_SESSION_ID` 虽然不是必填,但强烈建议配置。它确保所有通过 MCP 创建的任务、会话等数据都能关联到正确的开发迭代。你可以在 TestHub 前端的"开发管理"中找到活跃会话的 ID。
153
+
154
+ ## 使用说明
155
+
156
+ ### 基本工作流
157
+
158
+ 1. **开始任务**
159
+
160
+ 在 Cursor 中说:
161
+ ```
162
+ 开始任务 TASK-042
163
+ ```
164
+
165
+ AI 助手会:
166
+ - 调用 `testhub_get_task` 获取任务详情
167
+ - 显示任务标题、描述、验收标准
168
+ - 更新任务状态为"进行中"
169
+
170
+ 2. **开发完成后提交评审**
171
+
172
+ 在 Cursor 中说:
173
+ ```
174
+ 功能完成了,帮我提交评审
175
+ ```
176
+
177
+ AI 助手会:
178
+ - 分析修改的代码
179
+ - 自动生成评审文档(数据模型设计、API 设计、代码评审等)
180
+ - 上传文档到 TestHub
181
+ - 提交评审
182
+
183
+ 3. **结束会话**
184
+
185
+ 在 Cursor 中说:
186
+ ```
187
+ 今天先到这,同步一下
188
+ ```
189
+
190
+ AI 助手会:
191
+ - 整理本次会话的工作摘要
192
+ - 记录修改的文件、关键决策
193
+ - 同步到 TestHub
194
+
195
+ ### 可用命令
196
+
197
+ | 触发语句 | 功能 |
198
+ |---------|------|
199
+ | "开始任务 TASK-XXX" | 获取任务详情并开始任务 |
200
+ | "我的任务" | 查看待办任务列表 |
201
+ | "功能完成了" | 生成评审文档并提交 |
202
+ | "同步一下" | 同步当前会话记录 |
203
+ | "这里有个 bug" | 创建 Bug 报告 |
204
+
205
+ ## 可用工具
206
+
207
+ ### 任务管理
208
+
209
+ | 工具 | 说明 | 参数 |
210
+ |-----|------|------|
211
+ | `testhub_get_task` | 获取任务详情 | `task_code` (必填) |
212
+ | `testhub_update_task_status` | 更新任务状态 | `task_code`, `status` |
213
+ | `testhub_list_my_tasks` | 获取我的待办任务 | `status`, `limit` |
214
+ | `testhub_create_task` | 创建新任务 | `title`, `description`, `complexity` |
215
+ | `testhub_start_task` | 开始任务 | `task_code` |
216
+ | `testhub_complete_task` | 完成任务 | `task_code` |
217
+
218
+ ### 评审管理
219
+
220
+ | 工具 | 说明 | 参数 |
221
+ |-----|------|------|
222
+ | `testhub_create_review` | 创建功能评审 | `task_code` |
223
+ | `testhub_add_review_document` | 添加评审文档 | `task_code`, `doc_type`, `title`, `content` |
224
+ | `testhub_submit_review` | 提交评审 | `task_code` |
225
+
226
+ ### 会话管理
227
+
228
+ | 工具 | 说明 | 参数 |
229
+ |-----|------|------|
230
+ | `testhub_sync_dev_session` | 同步开发会话 | `session_summary`, `files_changed`, `key_decisions` |
231
+ | `testhub_list_sessions` | 列出开发会话 | `limit` |
232
+ | `testhub_switch_session` | 切换开发会话 | `session_id` |
233
+
234
+ ### Bug 管理
235
+
236
+ | 工具 | 说明 | 参数 |
237
+ |-----|------|------|
238
+ | `testhub_create_bug` | 创建 Bug | `title`, `description`, `severity`, `related_task_code` |
239
+
240
+ ### 上下文管理
241
+
242
+ | 工具 | 说明 | 参数 |
243
+ |-----|------|------|
244
+ | `testhub_get_context` | 获取当前上下文 | - |
245
+ | `testhub_switch_task` | 切换当前任务 | `task_code` |
246
+
247
+ ## 开发
248
+
249
+ ### 本地开发
250
+
251
+ ```bash
252
+ # 克隆仓库
253
+ git clone <repo-url>
254
+ cd TestHub/testhub_mcp
255
+
256
+ # 创建虚拟环境
257
+ python -m venv venv
258
+ source venv/bin/activate # Windows: venv\Scripts\activate
259
+
260
+ # 安装开发依赖
261
+ pip install -e ".[dev]"
262
+
263
+ # 运行测试
264
+ pytest
265
+ ```
266
+
267
+ ### 测试 MCP Server
268
+
269
+ 使用 MCP Inspector 进行测试:
270
+
271
+ ```bash
272
+ # 安装 MCP Inspector
273
+ npm install -g @modelcontextprotocol/inspector
274
+
275
+ # 启动测试
276
+ npx @modelcontextprotocol/inspector testhub-mcp
277
+ ```
278
+
279
+ ## 目录结构
280
+
281
+ ```
282
+ testhub_mcp/
283
+ ├── __init__.py # 包初始化
284
+ ├── server.py # MCP Server 主入口
285
+ ├── config.py # 配置管理
286
+ ├── api_client.py # TestHub API 客户端
287
+ ├── tools/ # MCP 工具实现
288
+ │ ├── __init__.py
289
+ │ ├── task.py # 任务管理工具
290
+ │ ├── review.py # 评审管理工具
291
+ │ ├── session.py # 会话同步工具
292
+ │ ├── bug.py # Bug 管理工具
293
+ │ └── docs.py # 文档工具
294
+ ├── resources/ # MCP 资源提供者
295
+ │ ├── __init__.py
296
+ │ └── docs.py # 文档资源
297
+ ├── pyproject.toml # 项目配置
298
+ └── README.md # 本文件
299
+ ```
300
+
301
+ ## 故障排除
302
+
303
+ ### MCP Server 无法启动
304
+
305
+ 1. 检查 Python 版本 >= 3.10
306
+ 2. 确认环境变量已正确配置
307
+ 3. 查看 Cursor 日志:`Help > Toggle Developer Tools > Console`
308
+
309
+ ### 无法连接 TestHub
310
+
311
+ 1. 检查 `TESTHUB_API_URL` 是否正确
312
+ 2. 确认 API Token 有效
313
+ 3. 确认网络可访问 TestHub 服务
314
+
315
+ ### 工具调用失败
316
+
317
+ 1. 检查必填参数是否提供
318
+ 2. 查看错误信息中的详细说明
319
+ 3. 确认对应的后端 API 已实现
320
+
321
+ ## 许可证
322
+
323
+ MIT
324
+
325
+ ## 相关链接
326
+
327
+ - [Model Context Protocol 官方文档](https://modelcontextprotocol.io/)
328
+ - [Cursor MCP 配置指南](https://docs.cursor.com/mcp)
329
+ - [TestHub 项目主页](../README.md)
330
+
@@ -0,0 +1,293 @@
1
+ # TestHub MCP Server
2
+
3
+ TestHub MCP Server 是一个 [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) 服务器,用于在 Cursor IDE 中集成 TestHub 开发管理系统。通过 MCP 协议,AI 助手可以直接与 TestHub 交互,实现任务管理、评审文档生成、会话同步等功能。
4
+
5
+ ## 功能特性
6
+
7
+ - 📋 **任务管理**:获取任务详情、更新状态、查看待办列表
8
+ - 📝 **评审文档**:自动生成设计文档、代码评审文档
9
+ - 💾 **会话同步**:记录开发会话、关键决策、修改文件
10
+ - 🐛 **Bug 管理**:快速创建 Bug 报告
11
+ - 📚 **文档访问**:访问项目文档资源
12
+
13
+ ## 快速开始
14
+
15
+ ### 前置要求
16
+
17
+ - Python >= 3.10
18
+ - Cursor IDE
19
+ - TestHub 后端服务运行中
20
+
21
+ ### 安装方式
22
+
23
+ #### 方式一:使用 uvx(推荐)
24
+
25
+ 无需单独安装,直接在 Cursor 配置中使用:
26
+
27
+ ```json
28
+ {
29
+ "mcpServers": {
30
+ "testhub": {
31
+ "command": "uvx",
32
+ "args": ["--from", "path/to/testhub_mcp", "testhub-mcp"],
33
+ "env": {
34
+ "TESTHUB_API_URL": "https://testhub.yourcompany.com/api/v1",
35
+ "TESTHUB_API_TOKEN": "your-personal-api-token",
36
+ "TESTHUB_TEAM_ID": "2",
37
+ "TESTHUB_SESSION_ID": "15"
38
+ }
39
+ }
40
+ }
41
+ }
42
+ ```
43
+
44
+ #### 方式二:使用 pip 安装
45
+
46
+ ```bash
47
+ # 进入 testhub_mcp 目录
48
+ cd testhub_mcp
49
+
50
+ # 安装到当前环境
51
+ pip install -e .
52
+
53
+ # 或使用 uv
54
+ uv pip install -e .
55
+ ```
56
+
57
+ ### 配置 Cursor
58
+
59
+ 1. 创建或编辑 Cursor MCP 配置文件:
60
+
61
+ **全局配置**(适用于所有项目):
62
+ ```
63
+ ~/.cursor/mcp.json
64
+ ```
65
+
66
+ **项目配置**(仅适用于当前项目):
67
+ ```
68
+ 项目根目录/.cursor/mcp.json
69
+ ```
70
+
71
+ 2. 添加以下配置:
72
+
73
+ ```json
74
+ {
75
+ "mcpServers": {
76
+ "testhub": {
77
+ "command": "testhub-mcp",
78
+ "env": {
79
+ "TESTHUB_API_URL": "https://testhub.yourcompany.com/api/v1",
80
+ "TESTHUB_API_TOKEN": "your-personal-api-token",
81
+ "TESTHUB_TEAM_ID": "2",
82
+ "TESTHUB_SESSION_ID": "15"
83
+ }
84
+ }
85
+ }
86
+ }
87
+ ```
88
+
89
+ ### 配置 Cursor Rules
90
+
91
+ 将 `cursor_rules/testhub-integration.mdc` 文件复制到项目的 `.cursor/rules/` 目录:
92
+
93
+ ```bash
94
+ mkdir -p .cursor/rules
95
+ cp cursor_rules/testhub-integration.mdc .cursor/rules/
96
+ ```
97
+
98
+ 或者手动创建符号链接(推荐,便于更新):
99
+
100
+ ```bash
101
+ mkdir -p .cursor/rules
102
+ ln -s ../../cursor_rules/testhub-integration.mdc .cursor/rules/testhub-integration.mdc
103
+ ```
104
+
105
+ ### 环境变量
106
+
107
+ | 变量名 | 必填 | 说明 | 示例 |
108
+ |-------|------|------|------|
109
+ | `TESTHUB_API_URL` | ✅ | TestHub API 地址 | `https://testhub.yourcompany.com/api/v1` |
110
+ | `TESTHUB_API_TOKEN` | ✅ | 个人 API Token | `th_xxx_xxxxx` |
111
+ | `TESTHUB_TEAM_ID` | ✅ | 团队 ID | `2` |
112
+ | `TESTHUB_SESSION_ID` | ⚠️ 推荐 | 默认开发会话 ID,创建任务时自动关联 | `15` |
113
+ | `PROJECT_DOCS_PATH` | ⬜ | 项目文档路径 | `./docs` |
114
+
115
+ > **💡 提示**:`TESTHUB_SESSION_ID` 虽然不是必填,但强烈建议配置。它确保所有通过 MCP 创建的任务、会话等数据都能关联到正确的开发迭代。你可以在 TestHub 前端的"开发管理"中找到活跃会话的 ID。
116
+
117
+ ## 使用说明
118
+
119
+ ### 基本工作流
120
+
121
+ 1. **开始任务**
122
+
123
+ 在 Cursor 中说:
124
+ ```
125
+ 开始任务 TASK-042
126
+ ```
127
+
128
+ AI 助手会:
129
+ - 调用 `testhub_get_task` 获取任务详情
130
+ - 显示任务标题、描述、验收标准
131
+ - 更新任务状态为"进行中"
132
+
133
+ 2. **开发完成后提交评审**
134
+
135
+ 在 Cursor 中说:
136
+ ```
137
+ 功能完成了,帮我提交评审
138
+ ```
139
+
140
+ AI 助手会:
141
+ - 分析修改的代码
142
+ - 自动生成评审文档(数据模型设计、API 设计、代码评审等)
143
+ - 上传文档到 TestHub
144
+ - 提交评审
145
+
146
+ 3. **结束会话**
147
+
148
+ 在 Cursor 中说:
149
+ ```
150
+ 今天先到这,同步一下
151
+ ```
152
+
153
+ AI 助手会:
154
+ - 整理本次会话的工作摘要
155
+ - 记录修改的文件、关键决策
156
+ - 同步到 TestHub
157
+
158
+ ### 可用命令
159
+
160
+ | 触发语句 | 功能 |
161
+ |---------|------|
162
+ | "开始任务 TASK-XXX" | 获取任务详情并开始任务 |
163
+ | "我的任务" | 查看待办任务列表 |
164
+ | "功能完成了" | 生成评审文档并提交 |
165
+ | "同步一下" | 同步当前会话记录 |
166
+ | "这里有个 bug" | 创建 Bug 报告 |
167
+
168
+ ## 可用工具
169
+
170
+ ### 任务管理
171
+
172
+ | 工具 | 说明 | 参数 |
173
+ |-----|------|------|
174
+ | `testhub_get_task` | 获取任务详情 | `task_code` (必填) |
175
+ | `testhub_update_task_status` | 更新任务状态 | `task_code`, `status` |
176
+ | `testhub_list_my_tasks` | 获取我的待办任务 | `status`, `limit` |
177
+ | `testhub_create_task` | 创建新任务 | `title`, `description`, `complexity` |
178
+ | `testhub_start_task` | 开始任务 | `task_code` |
179
+ | `testhub_complete_task` | 完成任务 | `task_code` |
180
+
181
+ ### 评审管理
182
+
183
+ | 工具 | 说明 | 参数 |
184
+ |-----|------|------|
185
+ | `testhub_create_review` | 创建功能评审 | `task_code` |
186
+ | `testhub_add_review_document` | 添加评审文档 | `task_code`, `doc_type`, `title`, `content` |
187
+ | `testhub_submit_review` | 提交评审 | `task_code` |
188
+
189
+ ### 会话管理
190
+
191
+ | 工具 | 说明 | 参数 |
192
+ |-----|------|------|
193
+ | `testhub_sync_dev_session` | 同步开发会话 | `session_summary`, `files_changed`, `key_decisions` |
194
+ | `testhub_list_sessions` | 列出开发会话 | `limit` |
195
+ | `testhub_switch_session` | 切换开发会话 | `session_id` |
196
+
197
+ ### Bug 管理
198
+
199
+ | 工具 | 说明 | 参数 |
200
+ |-----|------|------|
201
+ | `testhub_create_bug` | 创建 Bug | `title`, `description`, `severity`, `related_task_code` |
202
+
203
+ ### 上下文管理
204
+
205
+ | 工具 | 说明 | 参数 |
206
+ |-----|------|------|
207
+ | `testhub_get_context` | 获取当前上下文 | - |
208
+ | `testhub_switch_task` | 切换当前任务 | `task_code` |
209
+
210
+ ## 开发
211
+
212
+ ### 本地开发
213
+
214
+ ```bash
215
+ # 克隆仓库
216
+ git clone <repo-url>
217
+ cd TestHub/testhub_mcp
218
+
219
+ # 创建虚拟环境
220
+ python -m venv venv
221
+ source venv/bin/activate # Windows: venv\Scripts\activate
222
+
223
+ # 安装开发依赖
224
+ pip install -e ".[dev]"
225
+
226
+ # 运行测试
227
+ pytest
228
+ ```
229
+
230
+ ### 测试 MCP Server
231
+
232
+ 使用 MCP Inspector 进行测试:
233
+
234
+ ```bash
235
+ # 安装 MCP Inspector
236
+ npm install -g @modelcontextprotocol/inspector
237
+
238
+ # 启动测试
239
+ npx @modelcontextprotocol/inspector testhub-mcp
240
+ ```
241
+
242
+ ## 目录结构
243
+
244
+ ```
245
+ testhub_mcp/
246
+ ├── __init__.py # 包初始化
247
+ ├── server.py # MCP Server 主入口
248
+ ├── config.py # 配置管理
249
+ ├── api_client.py # TestHub API 客户端
250
+ ├── tools/ # MCP 工具实现
251
+ │ ├── __init__.py
252
+ │ ├── task.py # 任务管理工具
253
+ │ ├── review.py # 评审管理工具
254
+ │ ├── session.py # 会话同步工具
255
+ │ ├── bug.py # Bug 管理工具
256
+ │ └── docs.py # 文档工具
257
+ ├── resources/ # MCP 资源提供者
258
+ │ ├── __init__.py
259
+ │ └── docs.py # 文档资源
260
+ ├── pyproject.toml # 项目配置
261
+ └── README.md # 本文件
262
+ ```
263
+
264
+ ## 故障排除
265
+
266
+ ### MCP Server 无法启动
267
+
268
+ 1. 检查 Python 版本 >= 3.10
269
+ 2. 确认环境变量已正确配置
270
+ 3. 查看 Cursor 日志:`Help > Toggle Developer Tools > Console`
271
+
272
+ ### 无法连接 TestHub
273
+
274
+ 1. 检查 `TESTHUB_API_URL` 是否正确
275
+ 2. 确认 API Token 有效
276
+ 3. 确认网络可访问 TestHub 服务
277
+
278
+ ### 工具调用失败
279
+
280
+ 1. 检查必填参数是否提供
281
+ 2. 查看错误信息中的详细说明
282
+ 3. 确认对应的后端 API 已实现
283
+
284
+ ## 许可证
285
+
286
+ MIT
287
+
288
+ ## 相关链接
289
+
290
+ - [Model Context Protocol 官方文档](https://modelcontextprotocol.io/)
291
+ - [Cursor MCP 配置指南](https://docs.cursor.com/mcp)
292
+ - [TestHub 项目主页](../README.md)
293
+