Skip to main content
Glama

list_branches

Retrieve and sort branches in a Gitee repository by name or update date, filtering by owner, repo, and page settings. Simplify repository branch management.

Instructions

列出 Gitee 仓库中的分支

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directionNoSort directionasc
ownerYesRepository owner path (enterprise, organization, or personal path)
pageNoPage number
per_pageNoNumber of items per page, maximum 100
repoYesRepository path
sortNoSort fieldname

Implementation Reference

  • The core handler function that implements the logic to list branches from a Gitee repository by constructing the API URL with query parameters and fetching/parsing the response.
    export async function listBranches( owner: string, repo: string, sort?: string, direction?: string, page?: number, per_page?: number ) { owner = validateOwnerName(owner); repo = validateRepositoryName(repo); const url = new URL(`${getGiteeApiBaseUrl()}/repos/${owner}/${repo}/branches`); if (sort) { url.searchParams.append("sort", sort); } if (direction) { url.searchParams.append("direction", direction); } if (page !== undefined) { url.searchParams.append("page", page.toString()); } if (per_page !== undefined) { url.searchParams.append("per_page", per_page.toString()); } const response = await giteeRequest(url.toString()); return z.array(GiteeBranchSchema).parse(response); }
  • Zod schema defining the input parameters for the list_branches tool, including owner, repo, sorting, pagination options.
    export const ListBranchesSchema = z.object({ // 仓库所属空间地址 (企业、组织或个人的地址 path) owner: z.string().describe("Repository owner path (enterprise, organization, or personal path)"), // 仓库路径 (path) repo: z.string().describe("Repository path"), // 排序字段 sort: z.enum(["name", "updated"]).default("name").optional().describe("Sort field"), // 排序方向 direction: z.enum(["asc", "desc"]).default("asc").optional().describe("Sort direction"), // 当前的页码 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:72-87 (registration)
    Tool registration in the MCP server, specifying name, description, schema, and a wrapper handler that delegates to the implementation in branchOperations.
    server.registerTool({ name: "list_branches", description: "列出 Gitee 仓库中的分支", schema: branchOperations.ListBranchesSchema, handler: async (params: any) => { const { owner, repo, sort, direction, page, per_page } = params; return await branchOperations.listBranches( owner, repo, sort, direction, page, per_page ); }, });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/normal-coder/gitee-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server