list_organization_projects
Retrieve all projects within a GitHub organization, filtering by state and enabling pagination for efficient project management and organization-wide oversight.
Instructions
List all projects in a GitHub organization (at organization level, not repository level)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| org | Yes | Organization name | |
| page | No | Page number for pagination | |
| per_page | No | Number of results per page (max 100) | |
| state | No | Filter projects by state |
Implementation Reference
- operations/projects.ts:479-520 (handler)The main handler function that fetches and returns the list of projects for a given GitHub organization using the REST API.export async function listOrganizationProjects(org: string, state?: string, page?: number, perPage?: number) { try { const params: Record<string, string | number | undefined> = {}; if (state) { params.state = state; } if (page) { params.page = page; } if (perPage) { params.per_page = perPage; } let url = `https://api.github.com/orgs/${org}/projects`; // Thêm query params nếu có if (Object.keys(params).length > 0) { const queryString = new URLSearchParams(); Object.entries(params).forEach(([key, value]) => { if (value !== undefined) { queryString.append(key, String(value)); } }); url += `?${queryString.toString()}`; } return await githubRequest(url, { headers: { 'Accept': 'application/vnd.github.inertia-preview+json' } }); } catch (error) { if (error instanceof GitHubError) { throw error; } throw new GitHubError(`Failed to list organization projects: ${(error as Error).message}`, 500, { error: (error as Error).message }); } }
- operations/projects.ts:471-476 (schema)Zod schema defining the input parameters for the list_organization_projects tool.export const ListOrganizationProjectsSchema = z.object({ org: z.string().describe("Organization name"), state: z.enum(["open", "closed", "all"]).optional().describe("Filter projects by state"), page: z.number().optional().describe("Page number for pagination"), per_page: z.number().optional().describe("Number of results per page (max 100)"), });
- index.ts:266-269 (registration)Registers the list_organization_projects tool in the MCP server's list of available tools, including name, description, and input schema.name: "list_organization_projects", description: "List all projects in a GitHub organization (at organization level, not repository level)", inputSchema: zodToJsonSchema(projects.ListOrganizationProjectsSchema), },
- index.ts:722-733 (registration)Dispatches the call to the listOrganizationProjects handler function when the tool is invoked.case "list_organization_projects": { const args = projects.ListOrganizationProjectsSchema.parse(request.params.arguments); const result = await projects.listOrganizationProjects( args.org, args.state, args.page, args.per_page ); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }