get_current_user
Retrieve authenticated user details from Gitee's MCP server to manage repository files, branches, issues, and pull requests effectively.
Instructions
获取当前认证的 Gitee 用户信息
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {},
"type": "object"
}
Implementation Reference
- operations/users.ts:38-43 (handler)The core handler function for the 'get_current_user' tool. It performs a GET request to the Gitee '/user' endpoint and parses the response using GiteeUserSchema for output validation.export async function getCurrentUser() { const url = "/user"; const response = await giteeRequest(url, "GET"); return GiteeUserSchema.parse(response); }
- common/types.ts:4-35 (schema)The Zod schema used for parsing and validating the Gitee user response object, serving as the output type definition for the tool.export const GiteeUserSchema = z.object({ id: z.number().describe("The digital ID generated for a user after creation on Gitee, which remains constant and is not the username."), // 用户在 Gitee 创建后产生的数字 ID,恒定不变,不是用户名 login: z.string().describe("User login name"), // 用户登录名 name: z.string().nullable().describe("User name"), // 用户名称 avatar_url: z.string().url().nullable().describe("User avatar URL"), // 用户头像 URL url: z.string().url().describe("User API URL"), // 用户 API URL html_url: z.string().url().describe("User homepage URL"), // 用户主页 URL remark: z.string().nullable().describe("User remark"), // 用户备注 followers_url: z.string().url().describe("User followers URL"), // 用户关注者 URL following_url: z.string().url().describe("User following URL"), // 用户正在关注 URL gists_url: z.string().url().describe("User gists URL"), // 用户 Gists URL starred_url: z.string().url().describe("User starred URL"), // 用户星标 URL subscriptions_url: z.string().url().describe("User subscriptions URL"), // 用户订阅 URL organizations_url: z.string().url().describe("User organizations URL"), // 用户组织 URL repos_url: z.string().url().describe("User repositories URL"), // 用户仓库 URL events_url: z.string().url().describe("User events URL"), // 用户事件 URL received_events_url: z.string().url().describe("User received events URL"), // 用户接收的事件 URL type: z.string().describe("User type"), // 用户类型 site_admin: z.boolean().optional().default(false).describe("Whether the user is a site admin"), // 是否是网站管理员 blog: z.string().nullable().optional().describe("User blog"), // 用户博客 weibo: z.string().nullable().optional().describe("User Weibo"), // 用户微博 bio: z.string().nullable().optional().describe("User bio"), // 用户简介 public_repos: z.number().optional().describe("Number of public repositories"), // 公开仓库数量 public_gists: z.number().optional().describe("Number of public gists"), // 公开 Gists 数量 followers: z.number().optional().describe("Number of followers"), // 关注者数量 following: z.number().optional().describe("Number of following"), // 正在关注数量 stared: z.number().optional().describe("Number of stars"), // 星标数量 watched: z.number().optional().describe("Number of watched repositories"), // 关注数量 created_at: z.string().optional().describe("Creation time"), // 创建时间 updated_at: z.string().optional().describe("Update time"), // 更新时间 email: z.string().email().nullable().optional().describe("User email"), // 用户邮箱 });
- index.ts:263-270 (registration)The tool registration in the MCP server, specifying the name, description, empty input schema, and handler delegation to the implementation function.server.registerTool({ name: "get_current_user", description: "获取当前认证的 Gitee 用户信息", schema: z.object({}), handler: async () => { return await userOperations.getCurrentUser(); }, });