plane_api.go 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. package data
  2. import (
  3. "github.com/mark3labs/mcp-go/mcp"
  4. "github.com/mark3labs/mcp-go/server"
  5. )
  6. func registerPlaneApiTools(s *server.MCPServer) {
  7. // === Project ===
  8. s.AddTool(
  9. mcp.NewTool("data_plane_list_projects",
  10. mcp.WithDescription("列出 Plane 所有项目(V1 API)"),
  11. ),
  12. handlePlaneListProjects,
  13. )
  14. s.AddTool(
  15. mcp.NewTool("data_plane_get_project",
  16. mcp.WithDescription("获取 Plane 项目详情(V1 API)"),
  17. mcp.WithString("project_id", mcp.Required(), mcp.Description("项目 UUID")),
  18. ),
  19. handlePlaneGetProject,
  20. )
  21. s.AddTool(
  22. mcp.NewTool("data_plane_get_project_summary",
  23. mcp.WithDescription("获取 Plane 项目摘要统计(V1 API)"),
  24. mcp.WithString("project_id", mcp.Required(), mcp.Description("项目 UUID")),
  25. mcp.WithString("fields", mcp.Description("要获取的字段,逗号分隔")),
  26. ),
  27. handlePlaneGetProjectSummary,
  28. )
  29. // === Work Item ===
  30. s.AddTool(
  31. mcp.NewTool("data_plane_list_work_items",
  32. mcp.WithDescription("列出 Plane 工作项列表(V1 API)"),
  33. mcp.WithString("state", mcp.Description("状态ID过滤")),
  34. mcp.WithString("priority", mcp.Description("优先级过滤")),
  35. mcp.WithString("assignee", mcp.Description("指派人ID过滤")),
  36. mcp.WithString("label", mcp.Description("标签ID过滤")),
  37. ),
  38. handlePlaneListWorkItems,
  39. )
  40. s.AddTool(
  41. mcp.NewTool("data_plane_get_work_item",
  42. mcp.WithDescription("获取 Plane 工作项详情(V1 API)"),
  43. mcp.WithString("work_item_id", mcp.Required(), mcp.Description("工作项 UUID")),
  44. ),
  45. handlePlaneGetWorkItem,
  46. )
  47. s.AddTool(
  48. mcp.NewTool("data_plane_get_work_item_by_identifier",
  49. mcp.WithDescription("通过标识符获取工作项(如 PROJ-42)(V1 API)"),
  50. mcp.WithString("identifier", mcp.Required(), mcp.Description("项目标识符(如 PROJ)")),
  51. mcp.WithNumber("sequence_id", mcp.Required(), mcp.Description("序号(如 42)")),
  52. ),
  53. handlePlaneGetWorkItemByIdentifier,
  54. )
  55. s.AddTool(
  56. mcp.NewTool("data_plane_search_work_items",
  57. mcp.WithDescription("搜索 Plane 工作项(V1 API)"),
  58. mcp.WithString("query", mcp.Required(), mcp.Description("搜索关键字")),
  59. mcp.WithNumber("limit", mcp.Description("返回数量限制,默认20")),
  60. ),
  61. handlePlaneSearchWorkItems,
  62. )
  63. // === Cycle ===
  64. s.AddTool(
  65. mcp.NewTool("data_plane_list_cycles",
  66. mcp.WithDescription("列出 Plane 迭代列表(V1 API)"),
  67. ),
  68. handlePlaneListCycles,
  69. )
  70. s.AddTool(
  71. mcp.NewTool("data_plane_get_cycle",
  72. mcp.WithDescription("获取 Plane 迭代详情(V1 API)"),
  73. mcp.WithString("cycle_id", mcp.Required(), mcp.Description("迭代 UUID")),
  74. ),
  75. handlePlaneGetCycle,
  76. )
  77. s.AddTool(
  78. mcp.NewTool("data_plane_list_cycle_issues",
  79. mcp.WithDescription("列出 Plane 迭代中的工作项(V1 API)"),
  80. mcp.WithString("cycle_id", mcp.Required(), mcp.Description("迭代 UUID")),
  81. ),
  82. handlePlaneListCycleIssues,
  83. )
  84. // === Module ===
  85. s.AddTool(
  86. mcp.NewTool("data_plane_list_modules",
  87. mcp.WithDescription("列出 Plane 模块列表(V1 API)"),
  88. ),
  89. handlePlaneListModules,
  90. )
  91. s.AddTool(
  92. mcp.NewTool("data_plane_get_module",
  93. mcp.WithDescription("获取 Plane 模块详情(V1 API)"),
  94. mcp.WithString("module_id", mcp.Required(), mcp.Description("模块 UUID")),
  95. ),
  96. handlePlaneGetModule,
  97. )
  98. s.AddTool(
  99. mcp.NewTool("data_plane_list_module_issues",
  100. mcp.WithDescription("列出 Plane 模块中的工作项(V1 API)"),
  101. mcp.WithString("module_id", mcp.Required(), mcp.Description("模块 UUID")),
  102. ),
  103. handlePlaneListModuleIssues,
  104. )
  105. // === State / Label / Member ===
  106. s.AddTool(
  107. mcp.NewTool("data_plane_list_states",
  108. mcp.WithDescription("列出 Plane 项目状态列表(V1 API)"),
  109. ),
  110. handlePlaneListStates,
  111. )
  112. s.AddTool(
  113. mcp.NewTool("data_plane_list_labels",
  114. mcp.WithDescription("列出 Plane 项目标签列表(V1 API)"),
  115. ),
  116. handlePlaneListLabels,
  117. )
  118. s.AddTool(
  119. mcp.NewTool("data_plane_list_workspace_members",
  120. mcp.WithDescription("列出 Plane 工作空间成员(V1 API)"),
  121. ),
  122. handlePlaneListWorkspaceMembers,
  123. )
  124. s.AddTool(
  125. mcp.NewTool("data_plane_list_project_members",
  126. mcp.WithDescription("列出 Plane 项目成员(V1 API)"),
  127. ),
  128. handlePlaneListProjectMembers,
  129. )
  130. // === Comment / Activity / Attachment / Relation ===
  131. s.AddTool(
  132. mcp.NewTool("data_plane_list_work_item_comments",
  133. mcp.WithDescription("列出 Plane 工作项评论(V1 API)"),
  134. mcp.WithString("work_item_id", mcp.Required(), mcp.Description("工作项 UUID")),
  135. ),
  136. handlePlaneListWorkItemComments,
  137. )
  138. s.AddTool(
  139. mcp.NewTool("data_plane_list_work_item_activities",
  140. mcp.WithDescription("列出 Plane 工作项活动历史(V1 API)"),
  141. mcp.WithString("work_item_id", mcp.Required(), mcp.Description("工作项 UUID")),
  142. ),
  143. handlePlaneListWorkItemActivities,
  144. )
  145. s.AddTool(
  146. mcp.NewTool("data_plane_list_work_item_links",
  147. mcp.WithDescription("列出 Plane 工作项链接(V1 API)"),
  148. mcp.WithString("work_item_id", mcp.Required(), mcp.Description("工作项 UUID")),
  149. ),
  150. handlePlaneListWorkItemLinks,
  151. )
  152. s.AddTool(
  153. mcp.NewTool("data_plane_list_work_item_attachments",
  154. mcp.WithDescription("列出 Plane 工作项附件(V1 API)"),
  155. mcp.WithString("work_item_id", mcp.Required(), mcp.Description("工作项 UUID")),
  156. ),
  157. handlePlaneListWorkItemAttachments,
  158. )
  159. s.AddTool(
  160. mcp.NewTool("data_plane_list_work_item_relations",
  161. mcp.WithDescription("列出 Plane 工作项关系(V1 API)"),
  162. mcp.WithString("work_item_id", mcp.Required(), mcp.Description("工作项 UUID")),
  163. ),
  164. handlePlaneListWorkItemRelations,
  165. )
  166. // === Intake ===
  167. s.AddTool(
  168. mcp.NewTool("data_plane_get_intake_issue_list",
  169. mcp.WithDescription("查询 Plane Intake Issue 列表(V1 API)"),
  170. ),
  171. handlePlaneGetIntakeIssueList,
  172. )
  173. s.AddTool(
  174. mcp.NewTool("data_plane_get_intake_issue_detail",
  175. mcp.WithDescription("获取 Plane Intake Issue 详情(V1 API)"),
  176. mcp.WithString("intake_id", mcp.Required(), mcp.Description("Intake Issue UUID")),
  177. ),
  178. handlePlaneGetIntakeIssueDetail,
  179. )
  180. // === V2 Web API: Page ===
  181. s.AddTool(
  182. mcp.NewTool("data_plane_list_pages",
  183. mcp.WithDescription("列出 Plane 页面列表(V2 Web API)"),
  184. ),
  185. handlePlaneListPages,
  186. )
  187. s.AddTool(
  188. mcp.NewTool("data_plane_get_page",
  189. mcp.WithDescription("获取 Plane 页面详情(V2 Web API)"),
  190. mcp.WithString("page_id", mcp.Required(), mcp.Description("页面 UUID")),
  191. ),
  192. handlePlaneGetPage,
  193. )
  194. s.AddTool(
  195. mcp.NewTool("data_plane_get_page_description",
  196. mcp.WithDescription("获取 Plane 页面描述内容(V2 Web API)"),
  197. mcp.WithString("page_id", mcp.Required(), mcp.Description("页面 UUID")),
  198. ),
  199. handlePlaneGetPageDescription,
  200. )
  201. }