Skip to main content
Glama

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
NameRequiredDescriptionDefault
orgYesOrganization name
pageNoPage number for pagination
per_pageNoNumber of results per page (max 100)
stateNoFilter projects by state

Implementation Reference

  • 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 });
        }
    } 
  • 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) }],
      };
    }

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/tuanle96/mcp-github'

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