@xihe-lab/tapd-mcp-server 1.0.0

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.
Files changed (75) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +145 -0
  3. package/dist/index.d.ts +10 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +26 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/server.d.ts +6 -0
  8. package/dist/server.d.ts.map +1 -0
  9. package/dist/server.js +58 -0
  10. package/dist/server.js.map +1 -0
  11. package/dist/tapd-client.d.ts +17 -0
  12. package/dist/tapd-client.d.ts.map +1 -0
  13. package/dist/tapd-client.js +67 -0
  14. package/dist/tapd-client.js.map +1 -0
  15. package/dist/tools/bug.d.ts +3 -0
  16. package/dist/tools/bug.d.ts.map +1 -0
  17. package/dist/tools/bug.js +233 -0
  18. package/dist/tools/bug.js.map +1 -0
  19. package/dist/tools/comment.d.ts +3 -0
  20. package/dist/tools/comment.d.ts.map +1 -0
  21. package/dist/tools/comment.js +35 -0
  22. package/dist/tools/comment.js.map +1 -0
  23. package/dist/tools/index.d.ts +3 -0
  24. package/dist/tools/index.d.ts.map +1 -0
  25. package/dist/tools/index.js +29 -0
  26. package/dist/tools/index.js.map +1 -0
  27. package/dist/tools/iteration.d.ts +3 -0
  28. package/dist/tools/iteration.d.ts.map +1 -0
  29. package/dist/tools/iteration.js +86 -0
  30. package/dist/tools/iteration.js.map +1 -0
  31. package/dist/tools/release.d.ts +3 -0
  32. package/dist/tools/release.d.ts.map +1 -0
  33. package/dist/tools/release.js +24 -0
  34. package/dist/tools/release.js.map +1 -0
  35. package/dist/tools/settings.d.ts +3 -0
  36. package/dist/tools/settings.d.ts.map +1 -0
  37. package/dist/tools/settings.js +43 -0
  38. package/dist/tools/settings.js.map +1 -0
  39. package/dist/tools/story.d.ts +3 -0
  40. package/dist/tools/story.d.ts.map +1 -0
  41. package/dist/tools/story.js +166 -0
  42. package/dist/tools/story.js.map +1 -0
  43. package/dist/tools/task.d.ts +3 -0
  44. package/dist/tools/task.d.ts.map +1 -0
  45. package/dist/tools/task.js +125 -0
  46. package/dist/tools/task.js.map +1 -0
  47. package/dist/tools/test.d.ts +3 -0
  48. package/dist/tools/test.d.ts.map +1 -0
  49. package/dist/tools/test.js +44 -0
  50. package/dist/tools/test.js.map +1 -0
  51. package/dist/tools/timesheet.d.ts +3 -0
  52. package/dist/tools/timesheet.d.ts.map +1 -0
  53. package/dist/tools/timesheet.js +51 -0
  54. package/dist/tools/timesheet.js.map +1 -0
  55. package/dist/tools/user.d.ts +3 -0
  56. package/dist/tools/user.d.ts.map +1 -0
  57. package/dist/tools/user.js +24 -0
  58. package/dist/tools/user.js.map +1 -0
  59. package/dist/tools/wiki.d.ts +3 -0
  60. package/dist/tools/wiki.d.ts.map +1 -0
  61. package/dist/tools/wiki.js +24 -0
  62. package/dist/tools/wiki.js.map +1 -0
  63. package/dist/tools/workflow.d.ts +3 -0
  64. package/dist/tools/workflow.d.ts.map +1 -0
  65. package/dist/tools/workflow.js +30 -0
  66. package/dist/tools/workflow.js.map +1 -0
  67. package/dist/tools/workspace.d.ts +3 -0
  68. package/dist/tools/workspace.d.ts.map +1 -0
  69. package/dist/tools/workspace.js +47 -0
  70. package/dist/tools/workspace.js.map +1 -0
  71. package/dist/types.d.ts +17 -0
  72. package/dist/types.d.ts.map +1 -0
  73. package/dist/types.js +2 -0
  74. package/dist/types.js.map +1 -0
  75. package/package.json +57 -0
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 xihe-lab
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,145 @@
1
+ # TAPD MCP Server
2
+
3
+ [![CI](https://github.com/xihe-lab/tapd-mcp-server/actions/workflows/ci.yml/badge.svg)](https://github.com/xihe-lab/tapd-mcp-server/actions/workflows/ci.yml)
4
+ [![npm version](https://img.shields.io/npm/v/@xihe-lab/tapd-mcp-server.svg)](https://www.npmjs.com/package/@xihe-lab/tapd-mcp-server)
5
+ [![license](https://img.shields.io/github/license/xihe-lab/tapd-mcp-server.svg)](https://github.com/xihe-lab/tapd-mcp-server/blob/main/LICENSE)
6
+ [![Node.js](https://img.shields.io/node/v/@xihe-lab/tapd-mcp-server.svg)](https://www.npmjs.com/package/@xihe-lab/tapd-mcp-server)
7
+
8
+ 通过 [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) 将腾讯 TAPD 接入 Claude、Cursor 等 AI 助手,用自然语言管理需求、缺陷、任务和迭代。
9
+
10
+ ## 快速接入
11
+
12
+ ### 1. 获取凭证
13
+
14
+ 在 [TAPD 开放平台](https://open.tapd.cn) 创建应用,获取 Access Token。
15
+
16
+ ### 2. 配置 MCP 客户端
17
+
18
+ 需要 Node.js >= 18.0.0。无需手动安装,MCP 客户端会自动通过 npx 拉取。
19
+
20
+ #### Claude Desktop
21
+
22
+ 编辑 `~/Library/Application Support/Claude/claude_desktop_config.json`(macOS):
23
+
24
+ ```json
25
+ {
26
+ "mcpServers": {
27
+ "tapd": {
28
+ "command": "npx",
29
+ "args": ["-y", "@xihe-lab/tapd-mcp-server"],
30
+ "env": {
31
+ "TAPD_ACCESS_TOKEN": "your_access_token",
32
+ "TAPD_DEFAULT_WORKSPACE_ID": "your_workspace_id"
33
+ }
34
+ }
35
+ }
36
+ }
37
+ ```
38
+
39
+ #### Cursor / VS Code
40
+
41
+ 在项目根目录创建 `.cursor/mcp.json` 或 `.vscode/mcp.json`:
42
+
43
+ ```json
44
+ {
45
+ "mcpServers": {
46
+ "tapd": {
47
+ "command": "npx",
48
+ "args": ["-y", "@xihe-lab/tapd-mcp-server"],
49
+ "env": {
50
+ "TAPD_ACCESS_TOKEN": "your_access_token",
51
+ "TAPD_DEFAULT_WORKSPACE_ID": "your_workspace_id"
52
+ }
53
+ }
54
+ }
55
+ }
56
+ ```
57
+
58
+ #### Claude Code (CLI)
59
+
60
+ 在项目 `.claude/settings.local.json` 中配置:
61
+
62
+ ```json
63
+ {
64
+ "mcpServers": {
65
+ "tapd": {
66
+ "command": "npx",
67
+ "args": ["-y", "@xihe-lab/tapd-mcp-server"],
68
+ "env": {
69
+ "TAPD_ACCESS_TOKEN": "your_access_token",
70
+ "TAPD_DEFAULT_WORKSPACE_ID": "your_workspace_id"
71
+ }
72
+ }
73
+ }
74
+ }
75
+ ```
76
+
77
+ ### 3. 开始使用
78
+
79
+ 配置完成后重启客户端,直接用自然语言与 AI 助手对话:
80
+
81
+ > 查看我的待办需求
82
+
83
+ > 创建一个高优先级缺陷:登录页面报 500 错误
84
+
85
+ > 当前迭代的进度怎么样
86
+
87
+ > 给任务 10001 录入 3 小时工时
88
+
89
+ ## 环境变量
90
+
91
+ | 变量 | 必填 | 说明 |
92
+ |------|------|------|
93
+ | `TAPD_ACCESS_TOKEN` | 二选一 | Access Token(推荐) |
94
+ | `TAPD_API_USER` + `TAPD_API_PASSWORD` | 二选一 | 公司 ID + API Token(Basic Auth) |
95
+ | `TAPD_DEFAULT_WORKSPACE_ID` | 否 | 默认项目 ID,省去每次传 workspace_id |
96
+
97
+ ## 支持的能力
98
+
99
+ | 模块 | 可用操作 | 示例 |
100
+ |------|----------|------|
101
+ | 项目 | 查询项目信息、项目列表、成员列表 | "查看我参与的项目" |
102
+ | 需求 | 查询 / 创建 / 更新需求,统计数量 | "创建需求:用户登录功能" |
103
+ | 缺陷 | 查询 / 创建 / 更新缺陷,统计数量 | "查看我的未解决 Bug" |
104
+ | 任务 | 查询 / 创建 / 更新任务,统计数量 | "把任务标记为已完成" |
105
+ | 迭代 | 查询 / 创建 / 更新迭代,统计数量 | "当前迭代还有多少未完成" |
106
+ | 工时 | 查询工时记录、录入工时、统计 | "录入 4 小时工时" |
107
+ | 评论 | 查询和创建评论 | "给这个 Bug 加评论" |
108
+ | 工作流 | 查询状态流转规则 | "需求有哪些状态" |
109
+ | 配置 | 查询模块、版本、特性 | "项目有哪些模块" |
110
+ | 测试 | 查询测试用例和测试计划 | "查看测试计划" |
111
+ | Wiki | 查询项目文档 | "查看项目 Wiki" |
112
+ | 发布 | 查询发布计划 | "查看发布计划" |
113
+ | 用户 | 查询个人设置和角色 | "我的角色是什么" |
114
+
115
+ 共 **36 个工具**,覆盖 **13 个模块**。AI 助手会根据你的自然语言描述自动选择合适的工具。
116
+
117
+ ## 常见问题
118
+
119
+ ### AI 助手没有识别到 TAPD 工具
120
+
121
+ 确认 Node.js >= 18 已安装,npx 可正常执行。修改配置后需重启客户端。
122
+
123
+ ### 工具返回权限不足 (403)
124
+
125
+ 在 TAPD 开放平台检查应用权限,确保已勾选所需 API 的访问权限。
126
+
127
+ ### 支持 Basic Auth 吗
128
+
129
+ 支持。设置 `TAPD_API_USER` 和 `TAPD_API_PASSWORD` 即可,与 Access Token 二选一。
130
+
131
+ ## 本地开发
132
+
133
+ 如需二次开发:
134
+
135
+ ```bash
136
+ git clone git@github.com:xihe-lab/tapd-mcp-server.git && cd tapd-mcp-server
137
+ npm install && npm run build
138
+ npm run dev
139
+ ```
140
+
141
+ 添加新工具:在 `src/tools/` 下创建模块文件,导出 `ToolDef[]` 数组,然后在 `src/tools/index.ts` 中导入即可。
142
+
143
+ ## 许可证
144
+
145
+ [Apache-2.0](LICENSE)
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * TAPD MCP Server Entry Point
4
+ *
5
+ * This is the main entry point for the TAPD MCP server.
6
+ * It initializes the server, registers all tools, and starts
7
+ * the stdio transport for communication with MCP clients.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;GAMG"}
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * TAPD MCP Server Entry Point
4
+ *
5
+ * This is the main entry point for the TAPD MCP server.
6
+ * It initializes the server, registers all tools, and starts
7
+ * the stdio transport for communication with MCP clients.
8
+ */
9
+ import { start } from './server.js';
10
+ import { allTools } from './tools/index.js';
11
+ /**
12
+ * Start the MCP server
13
+ */
14
+ async function main() {
15
+ try {
16
+ await start(allTools);
17
+ // Server is now running and listening for requests via stdio
18
+ }
19
+ catch (error) {
20
+ console.error('Failed to start TAPD MCP server:', error);
21
+ process.exit(1);
22
+ }
23
+ }
24
+ // Start the server
25
+ main();
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;GAEG;AACH,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtB,6DAA6D;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,mBAAmB;AACnB,IAAI,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { ToolDef } from './types.js';
3
+ export declare function createServer(): McpServer;
4
+ export declare function registerTools(server: McpServer, tools: ToolDef[]): void;
5
+ export declare function start(tools: ToolDef[]): Promise<void>;
6
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAO1C,wBAAgB,YAAY,IAAI,SAAS,CAOxC;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAkCvE;AAED,wBAAsB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB3D"}
package/dist/server.js ADDED
@@ -0,0 +1,58 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { TapdClient } from './tapd-client.js';
4
+ function createTapdClient() {
5
+ return TapdClient.fromEnv();
6
+ }
7
+ export function createServer() {
8
+ const server = new McpServer({
9
+ name: 'tapd-mcp-server',
10
+ version: '1.0.0',
11
+ });
12
+ return server;
13
+ }
14
+ export function registerTools(server, tools) {
15
+ const client = createTapdClient();
16
+ for (const tool of tools) {
17
+ server.tool(tool.name, tool.description, tool.inputSchema.shape ?? tool.inputSchema, async (args) => {
18
+ try {
19
+ const result = await tool.handler(client, args);
20
+ return {
21
+ content: [
22
+ {
23
+ type: 'text',
24
+ text: JSON.stringify(result, null, 2),
25
+ },
26
+ ],
27
+ };
28
+ }
29
+ catch (error) {
30
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
31
+ return {
32
+ content: [
33
+ {
34
+ type: 'text',
35
+ text: JSON.stringify({ error: errorMessage }, null, 2),
36
+ },
37
+ ],
38
+ isError: true,
39
+ };
40
+ }
41
+ });
42
+ }
43
+ }
44
+ export async function start(tools) {
45
+ const server = createServer();
46
+ registerTools(server, tools);
47
+ const transport = new StdioServerTransport();
48
+ await server.connect(transport);
49
+ process.on('SIGINT', async () => {
50
+ await server.close();
51
+ process.exit(0);
52
+ });
53
+ process.on('SIGTERM', async () => {
54
+ await server.close();
55
+ process.exit(0);
56
+ });
57
+ }
58
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,SAAS,gBAAgB;IACvB,OAAO,UAAU,CAAC,OAAO,EAAE,CAAC;AAC9B,CAAC;AA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AAM,GAAG,YAAY,EAAE,CAAC;IAC9B,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAE7B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QAC/B,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,17 @@
1
+ export declare class TapdClient {
2
+ private authHeader;
3
+ private baseUrl;
4
+ private constructor();
5
+ static fromAccessToken(accessToken: string): TapdClient;
6
+ static fromBasicAuth(apiUser: string, apiPassword: string): TapdClient;
7
+ static fromEnv(): TapdClient;
8
+ request<T>(method: 'GET' | 'POST', path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
9
+ get<T>(path: string, params?: Record<string, string | number | boolean>): Promise<T>;
10
+ post<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
11
+ }
12
+ export interface TapdResponse<T> {
13
+ status: number;
14
+ data: T;
15
+ info: string;
16
+ }
17
+ //# sourceMappingURL=tapd-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tapd-client.d.ts","sourceRoot":"","sources":["../src/tapd-client.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU;IACrB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO;IAKP,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU;IAIvD,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,UAAU;IAKtE,MAAM,CAAC,OAAO,IAAI,UAAU;IAkBtB,OAAO,CAAC,CAAC,EACb,MAAM,EAAE,KAAK,GAAG,MAAM,EACtB,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,GAC7D,OAAO,CAAC,CAAC,CAAC;IA2CP,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAIpF,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAGxG;AAED,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -0,0 +1,67 @@
1
+ export class TapdClient {
2
+ authHeader;
3
+ baseUrl;
4
+ constructor(authHeader) {
5
+ this.authHeader = authHeader;
6
+ this.baseUrl = 'https://api.tapd.cn';
7
+ }
8
+ static fromAccessToken(accessToken) {
9
+ return new TapdClient(`Bearer ${accessToken}`);
10
+ }
11
+ static fromBasicAuth(apiUser, apiPassword) {
12
+ const credentials = `${apiUser}:${apiPassword}`;
13
+ return new TapdClient(`Basic ${Buffer.from(credentials).toString('base64')}`);
14
+ }
15
+ static fromEnv() {
16
+ const apiUser = process.env.TAPD_API_USER;
17
+ const apiPassword = process.env.TAPD_API_PASSWORD;
18
+ const accessToken = process.env.TAPD_ACCESS_TOKEN;
19
+ if (apiUser && apiPassword) {
20
+ return TapdClient.fromBasicAuth(apiUser, apiPassword);
21
+ }
22
+ if (accessToken) {
23
+ return TapdClient.fromAccessToken(accessToken);
24
+ }
25
+ throw new Error('Authentication required. Set TAPD_ACCESS_TOKEN or (TAPD_API_USER + TAPD_API_PASSWORD) environment variables.');
26
+ }
27
+ async request(method, path, params) {
28
+ const url = new URL(path, this.baseUrl);
29
+ const headers = {
30
+ 'Authorization': this.authHeader,
31
+ };
32
+ let body;
33
+ if (method === 'GET' && params) {
34
+ Object.entries(params).forEach(([key, value]) => {
35
+ if (value !== undefined) {
36
+ url.searchParams.append(key, String(value));
37
+ }
38
+ });
39
+ }
40
+ else if (method === 'POST' && params) {
41
+ headers['Content-Type'] = 'application/x-www-form-urlencoded';
42
+ body = new URLSearchParams(Object.entries(params)
43
+ .filter(([, value]) => value !== undefined)
44
+ .map(([key, value]) => [key, String(value)])).toString();
45
+ }
46
+ const response = await fetch(url.toString(), {
47
+ method,
48
+ headers,
49
+ body,
50
+ });
51
+ if (!response.ok) {
52
+ throw new Error(`TAPD API error: ${response.status} ${response.statusText}`);
53
+ }
54
+ const result = await response.json();
55
+ if (result.status !== 1) {
56
+ throw new Error(`TAPD API error: ${result.info || 'Unknown error'}`);
57
+ }
58
+ return result.data;
59
+ }
60
+ async get(path, params) {
61
+ return this.request('GET', path, params);
62
+ }
63
+ async post(path, params) {
64
+ return this.request('POST', path, params);
65
+ }
66
+ }
67
+ //# sourceMappingURL=tapd-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tapd-client.js","sourceRoot":"","sources":["../src/tapd-client.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAU;IACb,UAAU,CAAS;IACnB,OAAO,CAAS;IAExB,YAAoB,UAAkB;QACpC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,qBAAqB,CAAC;IACvC,CAAC;IAED,MAA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;QAC3E,OAAO,IAAI,CAAC,OAAO,CAAI,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,IAAI,CAAI,IAAY,EAAE,MAA8D;QACxF,OAAO,IAAI,CAAC,OAAO,CAAI,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ import type { ToolDef } from '../types.js';
2
+ export declare const bugTools: ToolDef[];
3
+ //# sourceMappingURL=bug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bug.d.ts","sourceRoot":"","sources":["../../src/tools/bug.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,eAAO,MAAM,QAAQ,EAAE,OAAO,EAsO7B,CAAC"}