list_pull_requests
Retrieve Pull Requests from Gitee repositories by specifying owner, repo, state, sort, and other filters to manage PRs effectively.
Instructions
列出 Gitee 仓库中的 Pull Requests
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"owner": "<owner>",
"repo": "<repo>"
},
"name": "list_pull_requests"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| direction | No | Sort direction | desc |
| labels | No | Labels, multiple labels separated by commas | |
| milestone | No | Milestone ID | |
| owner | Yes | Repository owner path (enterprise, organization, or personal path) | |
| page | No | Page number | |
| per_page | No | Number of items per page, maximum 100 | |
| repo | Yes | Repository path | |
| sort | No | Sort field | created |
| state | No | Pull Request state | open |
Implementation Reference
- operations/pulls.ts:126-146 (handler)The main handler function that lists pull requests by constructing the Gitee API URL with query parameters from options and fetching/parsing the response.
export async function listPullRequests( owner: string, repo: string, options: Omit<ListPullRequestsOptions, "owner" | "repo"> ) { owner = validateOwnerName(owner); repo = validateRepositoryName(repo); const url = new URL(`${getGiteeApiBaseUrl()}/repos/${owner}/${repo}/pulls`); // Add query parameters Object.entries(options).forEach(([key, value]) => { if (value !== undefined) { url.searchParams.append(key, value.toString()); } }); const response = await giteeRequest(url.toString(), "GET"); return z.array(GiteePullRequestSchema).parse(response); } - operations/pulls.ts:33-52 (schema)Zod schema defining the input parameters for the list_pull_requests tool, including owner, repo, pagination, filtering, and sorting options.
export const ListPullRequestsSchema = z.object({ // 仓库所属空间地址 (企业、组织或个人的地址 path) owner: z.string().describe("Repository owner path (enterprise, organization, or personal path)"), // 仓库路径 (path) repo: z.string().describe("Repository path"), // Pull Request 状态 state: z.enum(["open", "closed", "merged", "all"]).default("open").optional().describe("Pull Request state"), // 排序字段 sort: z.enum(["created", "updated", "popularity", "long-running"]).default("created").optional().describe("Sort field"), // 排序方向 direction: z.enum(["asc", "desc"]).default("desc").optional().describe("Sort direction"), // 里程碑 ID milestone: z.number().optional().describe("Milestone ID"), // 标签,多个标签以逗号分隔 labels: z.string().optional().describe("Labels, multiple labels separated by commas"), // 当前的页码 page: z.number().int().default(1).optional().describe("Page number"), // 每页的数量,最大为 100 per_page: z.number().int().min(1).max(100).optional().describe("Number of items per page, maximum 100"), }); - index.ts:204-212 (registration)Registers the list_pull_requests tool with the MCP server, using the schema from pullOperations and delegating to the listPullRequests handler.
server.registerTool({ name: "list_pull_requests", description: "列出 Gitee 仓库中的 Pull Requests", schema: pullOperations.ListPullRequestsSchema, handler: async (params: any) => { const { owner, repo, ...options } = params; return await pullOperations.listPullRequests(owner, repo, options); }, });