pub(crate) mod args; pub(crate) mod helpers; pub(crate) mod issue; pub(crate) mod me; pub(crate) mod pull; pub(crate) mod repo; pub(crate) mod space; use rmcp::ErrorData; use rmcp::handler::server::wrapper::Parameters; use rmcp::model::CallToolResult; use rmcp::service::RequestContext; use rmcp::{RoleServer, tool, tool_router}; use crate::McpServer; #[tool_router(vis = "pub(crate)")] impl McpServer { #[tool( description = "返回当前访问密钥对应的用户身份,以及密钥的读写范围(scope)。", annotations(read_only_hint = true) )] async fn me_get(&self, ctx: RequestContext) -> Result { let principal = self.principal(&ctx)?; Ok(me::get(&self.services, &principal).await) } #[tool( description = "查询当前访问密钥的用户在指定 space 中的全部有效权限(view_space/read/message/manage_*)。", annotations(read_only_hint = true) )] async fn me_space_permissions( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(me::space_permissions(&self.services, &principal, args).await) } #[tool( description = "查询当前访问密钥的用户在指定仓库上的 read/write/admin 权限。", annotations(read_only_hint = true) )] async fn me_repo_permissions( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(me::repo_permissions(&self.services, &principal, args).await) } #[tool( description = "返回当前访问密钥的用户拥有的 space 列表。", annotations(read_only_hint = true) )] async fn me_spaces( &self, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(me::my_spaces(&self.services, &principal).await) } #[tool( description = "按用户名或 UID 查询平台用户的公开资料。", annotations(read_only_hint = true) )] async fn user_get( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(me::user_get(&self.services, &principal, args).await) } #[tool( description = "按一组 UID 批量查询平台用户公开资料(最多 100 个)。", annotations(read_only_hint = true) )] async fn users_get( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(me::users_get(&self.services, &principal, args).await) } #[tool( description = "列出当前用户拥有的 space。", annotations(read_only_hint = true) )] async fn space_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::list(&self.services, &principal, args).await) } #[tool( description = "浏览公开 space(未私有的可加入空间)。", annotations(read_only_hint = true) )] async fn space_explore( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::explore(&self.services, &principal, args).await) } #[tool( description = "按名称获取 space 详情(私有时需要成员权限)。", annotations(read_only_hint = true) )] async fn space_get( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::get(&self.services, &principal, args).await) } #[tool(description = "创建 space(当前用户成为所有者)。")] async fn space_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::create(&self.services, &principal, args).await) } #[tool(description = "更新 space 设置(仅所有者)。")] async fn space_update( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::update(&self.services, &principal, args).await) } #[tool( description = "停用(软删除)space(仅所有者)。", annotations(destructive_hint = true) )] async fn space_delete( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::delete(&self.services, &principal, args).await) } #[tool(description = "列出 space 成员。", annotations(read_only_hint = true))] async fn space_member_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::member_list(&self.services, &principal, args).await) } #[tool(description = "添加 space 成员(需要 manage_members 权限)。")] async fn space_member_add( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::member_add(&self.services, &principal, args).await) } #[tool(description = "更新 space 成员属性(需要 manage_members 权限)。")] async fn space_member_update( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::member_update(&self.services, &principal, args).await) } #[tool( description = "移除 space 成员(需要 manage_members 权限)。", annotations(destructive_hint = true) )] async fn space_member_remove( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::member_remove(&self.services, &principal, args).await) } #[tool(description = "主动退出 space(所有者不可退出)。")] async fn space_member_leave( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::member_leave(&self.services, &principal, args).await) } #[tool( description = "列出 space 的角色组(需要 manage_roles 权限)。", annotations(read_only_hint = true) )] async fn space_group_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::group_list(&self.services, &principal, args).await) } #[tool(description = "创建 space 角色组(需要 manage_roles 权限)。")] async fn space_group_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::group_create(&self.services, &principal, args).await) } #[tool(description = "更新 space 角色组(需要 manage_roles 权限)。")] async fn space_group_update( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::group_update(&self.services, &principal, args).await) } #[tool( description = "删除 space 角色组(需要 manage_roles 权限)。", annotations(destructive_hint = true) )] async fn space_group_delete( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::group_delete(&self.services, &principal, args).await) } #[tool(description = "把成员加入角色组(需要 manage_roles 权限)。")] async fn space_group_assign( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::group_assign(&self.services, &principal, args).await) } #[tool(description = "把成员移出角色组(需要 manage_roles 权限)。")] async fn space_group_unassign( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::group_unassign(&self.services, &principal, args).await) } #[tool( description = "获取 space 的目录树(可见性受目录覆盖规则限制)。", annotations(read_only_hint = true) )] async fn space_dir_tree( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::dir_tree(&self.services, &principal, args).await) } #[tool(description = "创建目录节点(需要 manage_channels 权限)。")] async fn space_dir_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::dir_create(&self.services, &principal, args).await) } #[tool(description = "重命名目录节点(需要 manage_channels 权限)。")] async fn space_dir_update( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::dir_update(&self.services, &principal, args).await) } #[tool(description = "移动目录节点(需要 manage_channels 权限)。")] async fn space_dir_move( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::dir_move(&self.services, &principal, args).await) } #[tool( description = "列出 space 邀请(需要 manage_invites 权限)。", annotations(read_only_hint = true) )] async fn space_invite_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::invite_list(&self.services, &principal, args).await) } #[tool(description = "创建 space 邀请(需要 manage_invites 权限)。")] async fn space_invite_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::invite_create(&self.services, &principal, args).await) } #[tool( description = "撤销 space 邀请(需要 manage_invites 权限)。", annotations(destructive_hint = true) )] async fn space_invite_revoke( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::invite_revoke(&self.services, &principal, args).await) } #[tool( description = "列出 space 加入申请(需要 manage_members 权限)。", annotations(read_only_hint = true) )] async fn space_join_request_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::join_request_list(&self.services, &principal, args).await) } #[tool(description = "提交加入 space 的申请。")] async fn space_join_request_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::join_request_create(&self.services, &principal, args).await) } #[tool(description = "撤回自己的加入申请。")] async fn space_join_request_withdraw( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::join_request_withdraw(&self.services, &principal, args).await) } #[tool(description = "通过加入申请(需要 manage_members 权限)。")] async fn space_join_request_approve( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::join_request_approve(&self.services, &principal, args).await) } #[tool(description = "拒绝加入申请(需要 manage_members 权限)。")] async fn space_join_request_reject( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(space::join_request_reject(&self.services, &principal, args).await) } #[tool( description = "列出 space 下的仓库(私有仓库仅协作者可见)。", annotations(read_only_hint = true) )] async fn repo_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::list(&self.services, &principal, args).await) } #[tool( description = "获取仓库详情(需要读权限)。", annotations(read_only_hint = true) )] async fn repo_get( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::get(&self.services, &principal, args).await) } #[tool(description = "在 space 下创建仓库(需要 space 所有者权限)。")] async fn repo_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::create(&self.services, &principal, args).await) } #[tool(description = "更新仓库设置(需要 space 所有者权限)。")] async fn repo_update( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::update(&self.services, &principal, args).await) } #[tool(description = "归档或取消归档仓库(需要 space 所有者权限)。")] async fn repo_set_archived( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::set_archived(&self.services, &principal, args).await) } #[tool(description = "列出仓库分支。", annotations(read_only_hint = true))] async fn repo_branch_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::branch_list(&self.services, &principal, args).await) } #[tool(description = "获取单个分支信息。", annotations(read_only_hint = true))] async fn repo_branch_get( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::branch_get(&self.services, &principal, args).await) } #[tool(description = "创建分支(需要仓库写权限)。")] async fn repo_branch_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::branch_create(&self.services, &principal, args).await) } #[tool(description = "重命名分支(需要仓库写权限)。")] async fn repo_branch_rename( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::branch_rename(&self.services, &principal, args).await) } #[tool( description = "删除分支(需要仓库写权限)。", annotations(destructive_hint = true) )] async fn repo_branch_delete( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::branch_delete(&self.services, &principal, args).await) } #[tool(description = "设置默认分支(需要仓库写权限)。")] async fn repo_branch_set_default( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::branch_set_default(&self.services, &principal, args).await) } #[tool(description = "列出仓库标签。", annotations(read_only_hint = true))] async fn repo_tag_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::tag_list(&self.services, &principal, args).await) } #[tool(description = "获取单个标签。", annotations(read_only_hint = true))] async fn repo_tag_get( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::tag_get(&self.services, &principal, args).await) } #[tool(description = "创建标签(需要仓库写权限)。")] async fn repo_tag_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::tag_create(&self.services, &principal, args).await) } #[tool( description = "删除标签(需要仓库写权限)。", annotations(destructive_hint = true) )] async fn repo_tag_delete( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::tag_delete(&self.services, &principal, args).await) } #[tool( description = "列出提交历史(可按路径/数量过滤)。", annotations(read_only_hint = true) )] async fn repo_commit_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::commit_list(&self.services, &principal, args).await) } #[tool(description = "获取单个提交详情。", annotations(read_only_hint = true))] async fn repo_commit_get( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::commit_get(&self.services, &principal, args).await) } #[tool( description = "浏览仓库目录树(recurse=true 递归列出全部条目)。", annotations(read_only_hint = true) )] async fn repo_tree( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::tree(&self.services, &principal, args).await) } #[tool( description = "按路径读取仓库文件内容(文本返回 utf-8,二进制返回 base64)。", annotations(read_only_hint = true) )] async fn repo_file_get( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::file_get(&self.services, &principal, args).await) } #[tool(description = "列出仓库 Release。", annotations(read_only_hint = true))] async fn repo_release_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::release_list(&self.services, &principal, args).await) } #[tool( description = "按 tag 获取 Release。", annotations(read_only_hint = true) )] async fn repo_release_get( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::release_get(&self.services, &principal, args).await) } #[tool(description = "创建 Release(需要仓库写权限)。")] async fn repo_release_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::release_create(&self.services, &principal, args).await) } #[tool(description = "更新 Release(发布者或仓库管理员)。")] async fn repo_release_update( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::release_update(&self.services, &principal, args).await) } #[tool( description = "删除 Release(发布者或仓库管理员)。", annotations(destructive_hint = true) )] async fn repo_release_delete( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::release_delete(&self.services, &principal, args).await) } #[tool(description = "列出仓库 topics。", annotations(read_only_hint = true))] async fn repo_topic_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::topic_list(&self.services, &principal, args).await) } #[tool(description = "为仓库添加 topic(需要仓库写权限)。")] async fn repo_topic_add( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::topic_add(&self.services, &principal, args).await) } #[tool(description = "移除仓库 topic(需要仓库写权限)。")] async fn repo_topic_remove( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::topic_remove(&self.services, &principal, args).await) } #[tool(description = "收藏仓库。")] async fn repo_star( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::star(&self.services, &principal, args).await) } #[tool(description = "取消收藏仓库。")] async fn repo_unstar( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::unstar(&self.services, &principal, args).await) } #[tool(description = "设置仓库关注模式(unwatched/watching/ignore)。")] async fn repo_watch( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::watch(&self.services, &principal, args).await) } #[tool(description = "列出仓库收藏者。", annotations(read_only_hint = true))] async fn repo_stargazers( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::stargazers(&self.services, &principal, args).await) } #[tool(description = "列出仓库关注者。", annotations(read_only_hint = true))] async fn repo_watchers( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(repo::watchers(&self.services, &principal, args).await) } #[tool( description = "列出 space 内的 issue 看板。", annotations(read_only_hint = true) )] async fn issue_board_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::board_list(&self.services, &principal, args).await) } #[tool( description = "获取 issue 看板详情。", annotations(read_only_hint = true) )] async fn issue_board_get( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::board_get(&self.services, &principal, args).await) } #[tool(description = "创建 issue 看板(需要 manage_channels 权限)。")] async fn issue_board_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::board_create(&self.services, &principal, args).await) } #[tool(description = "更新 issue 看板(需要管理权限)。")] async fn issue_board_update( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::board_update(&self.services, &principal, args).await) } #[tool( description = "删除 issue 看板(需要管理权限)。", annotations(destructive_hint = true) )] async fn issue_board_delete( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::board_delete(&self.services, &principal, args).await) } #[tool( description = "分页/过滤查询 issue。", annotations(read_only_hint = true) )] async fn issue_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::list(&self.services, &principal, args).await) } #[tool( description = "获取 issue 详情(issue_id 支持 UUID 或看板内编号)。", annotations(read_only_hint = true) )] async fn issue_get( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::get(&self.services, &principal, args).await) } #[tool(description = "创建 issue。")] async fn issue_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::create(&self.services, &principal, args).await) } #[tool(description = "更新 issue(作者或看板管理员)。")] async fn issue_update( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::update(&self.services, &principal, args).await) } #[tool( description = "删除 issue(作者或看板管理员)。", annotations(destructive_hint = true) )] async fn issue_delete( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::delete(&self.services, &principal, args).await) } #[tool(description = "关闭 issue。")] async fn issue_close( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::set_closed(&self.services, &principal, args, true).await) } #[tool(description = "重新打开 issue。")] async fn issue_reopen( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::set_closed(&self.services, &principal, args, false).await) } #[tool(description = "列出 issue 评论。", annotations(read_only_hint = true))] async fn issue_comment_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::comment_list(&self.services, &principal, args).await) } #[tool(description = "发表 issue 评论。")] async fn issue_comment_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::comment_create(&self.services, &principal, args).await) } #[tool(description = "更新 issue 评论(作者或看板管理员)。")] async fn issue_comment_update( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::comment_update(&self.services, &principal, args).await) } #[tool( description = "删除 issue 评论(作者或看板管理员)。", annotations(destructive_hint = true) )] async fn issue_comment_delete( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::comment_delete(&self.services, &principal, args).await) } #[tool(description = "列出看板标签。", annotations(read_only_hint = true))] async fn issue_label_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::label_list(&self.services, &principal, args).await) } #[tool(description = "创建看板标签(需要看板管理权限)。")] async fn issue_label_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::label_create(&self.services, &principal, args).await) } #[tool(description = "更新看板标签(需要看板管理权限)。")] async fn issue_label_update( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::label_update(&self.services, &principal, args).await) } #[tool( description = "删除看板标签(需要看板管理权限)。", annotations(destructive_hint = true) )] async fn issue_label_delete( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::label_delete(&self.services, &principal, args).await) } #[tool(description = "给 issue 绑定标签。")] async fn issue_label_bind( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::label_bind(&self.services, &principal, args).await) } #[tool(description = "解绑 issue 标签。")] async fn issue_label_unbind( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::label_unbind(&self.services, &principal, args).await) } #[tool(description = "列出看板里程碑。", annotations(read_only_hint = true))] async fn issue_milestone_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::milestone_list(&self.services, &principal, args).await) } #[tool(description = "创建看板里程碑(需要看板管理权限)。")] async fn issue_milestone_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::milestone_create(&self.services, &principal, args).await) } #[tool(description = "更新看板里程碑(需要看板管理权限)。")] async fn issue_milestone_update( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::milestone_update(&self.services, &principal, args).await) } #[tool( description = "删除看板里程碑(需要看板管理权限)。", annotations(destructive_hint = true) )] async fn issue_milestone_delete( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::milestone_delete(&self.services, &principal, args).await) } #[tool( description = "列出 issue 成员(参与者/关注者等)。", annotations(read_only_hint = true) )] async fn issue_member_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::member_list(&self.services, &principal, args).await) } #[tool(description = "添加 issue 成员(需要看板管理权限)。")] async fn issue_member_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::member_create(&self.services, &principal, args).await) } #[tool( description = "移除 issue 成员(需要看板管理权限)。", annotations(destructive_hint = true) )] async fn issue_member_delete( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::member_delete(&self.services, &principal, args).await) } #[tool(description = "列出看板置顶。", annotations(read_only_hint = true))] async fn issue_pin_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::pin_list(&self.services, &principal, args).await) } #[tool(description = "置顶 issue(需要看板管理权限)。")] async fn issue_pin_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::pin_create(&self.services, &principal, args).await) } #[tool(description = "调整置顶顺序(需要看板管理权限)。")] async fn issue_pin_update( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::pin_update(&self.services, &principal, args).await) } #[tool( description = "取消置顶(需要看板管理权限)。", annotations(destructive_hint = true) )] async fn issue_pin_delete( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::pin_delete(&self.services, &principal, args).await) } #[tool(description = "列出 issue 依赖。", annotations(read_only_hint = true))] async fn issue_dependency_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::dependency_list(&self.services, &principal, args).await) } #[tool(description = "添加 issue 依赖(需要看板管理权限)。")] async fn issue_dependency_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::dependency_create(&self.services, &principal, args).await) } #[tool( description = "删除 issue 依赖(需要看板管理权限)。", annotations(destructive_hint = true) )] async fn issue_dependency_delete( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(issue::dependency_delete(&self.services, &principal, args).await) } #[tool( description = "列出仓库的合并请求。", annotations(read_only_hint = true) )] async fn pull_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::list(&self.services, &principal, args).await) } #[tool( description = "获取合并请求详情(pull 支持编号或 UUID)。", annotations(read_only_hint = true) )] async fn pull_get( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::get(&self.services, &principal, args).await) } #[tool(description = "创建合并请求(需要仓库写权限)。")] async fn pull_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::create(&self.services, &principal, args).await) } #[tool(description = "更新合并请求(需要仓库写权限)。")] async fn pull_update( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::update(&self.services, &principal, args).await) } #[tool(description = "关闭合并请求(作者或仓库管理员)。")] async fn pull_close( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::set_state(&self.services, &principal, args, true).await) } #[tool(description = "重新打开合并请求(作者或仓库管理员)。")] async fn pull_reopen( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::set_state(&self.services, &principal, args, false).await) } #[tool( description = "删除合并请求(仅仓库管理员)。", annotations(destructive_hint = true) )] async fn pull_delete( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::delete(&self.services, &principal, args).await) } #[tool( description = "合并合并请求(受分支保护与审批门槛限制)。", annotations(destructive_hint = true) )] async fn pull_merge( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::merge(&self.services, &principal, args).await) } #[tool(description = "列出合并请求评论。", annotations(read_only_hint = true))] async fn pull_comment_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::comment_list(&self.services, &principal, args).await) } #[tool(description = "发表合并请求评论。")] async fn pull_comment_create( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::comment_create(&self.services, &principal, args).await) } #[tool(description = "更新合并请求评论(作者或管理员)。")] async fn pull_comment_update( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::comment_update(&self.services, &principal, args).await) } #[tool( description = "删除合并请求评论(作者或管理员)。", annotations(destructive_hint = true) )] async fn pull_comment_delete( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::comment_delete(&self.services, &principal, args).await) } #[tool(description = "标记/取消标记评论已解决。")] async fn pull_comment_resolve( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::comment_resolve(&self.services, &principal, args).await) } #[tool( description = "列出合并请求的评审。", annotations(read_only_hint = true) )] async fn pull_review_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::review_list(&self.services, &principal, args).await) } #[tool(description = "提交评审(approve/request_changes/comment)。")] async fn pull_review_submit( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::review_submit(&self.services, &principal, args).await) } #[tool(description = "驳回评审(需要管理员)。")] async fn pull_review_dismiss( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::review_dismiss(&self.services, &principal, args).await) } #[tool(description = "列出评审请求。", annotations(read_only_hint = true))] async fn pull_reviewer_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::reviewer_list(&self.services, &principal, args).await) } #[tool(description = "请求评审人(需要仓库写权限)。")] async fn pull_reviewer_request( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::reviewer_request(&self.services, &principal, args).await) } #[tool(description = "取消评审请求(需要仓库写权限)。")] async fn pull_reviewer_cancel( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::reviewer_cancel(&self.services, &principal, args).await) } #[tool( description = "列出合并请求指派人。", annotations(read_only_hint = true) )] async fn pull_assignee_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::assignee_list(&self.services, &principal, args).await) } #[tool(description = "指派合并请求负责人(需要仓库写权限)。")] async fn pull_assignee_add( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::assignee_add(&self.services, &principal, args).await) } #[tool(description = "移除合并请求负责人(需要仓库写权限)。")] async fn pull_assignee_remove( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::assignee_remove(&self.services, &principal, args).await) } #[tool(description = "列出合并请求标签。", annotations(read_only_hint = true))] async fn pull_label_list( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::label_list(&self.services, &principal, args).await) } #[tool(description = "给合并请求添加标签(需要仓库写权限)。")] async fn pull_label_attach( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::label_attach(&self.services, &principal, args).await) } #[tool(description = "移除合并请求标签(需要仓库写权限)。")] async fn pull_label_detach( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::label_detach(&self.services, &principal, args).await) } #[tool( description = "查看合并请求的 CI 检查状态。", annotations(read_only_hint = true) )] async fn pull_checks( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::checks(&self.services, &principal, args).await) } #[tool( description = "查看合并请求的合并门槛(分支保护/审批)。", annotations(read_only_hint = true) )] async fn pull_gate( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::gate(&self.services, &principal, args).await) } #[tool( description = "查看我的合并请求收件箱(created/review-requested/reviewed,scope 用 kebab-case)。", annotations(read_only_hint = true) )] async fn pull_inbox( &self, Parameters(args): Parameters, ctx: RequestContext, ) -> Result { let principal = self.principal(&ctx)?; Ok(pull::inbox(&self.services, &principal, args).await) } }