list_projects
Generate and filter GitHub project lists by status using a precise input schema, enabling efficient project management within the mcp-github-project-manager server.
Instructions
List GitHub projects
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| status | Yes |
Implementation Reference
- Main handler function that executes the list_projects tool logic. Fetches all projects from repository, filters by status, applies limit, and returns the list.async listProjects(status: string = 'active', limit: number = 10): Promise<Project[]> { try { const projects = await this.projectRepo.findAll(); // Filter by status if needed let filteredProjects = projects; if (status !== 'all') { const resourceStatus = status === 'active' ? ResourceStatus.ACTIVE : ResourceStatus.CLOSED; filteredProjects = projects.filter(project => project.status === resourceStatus); } // Apply limit return filteredProjects.slice(0, limit); } catch (error) { throw this.mapErrorToMCPError(error); } }
- Tool schema definition including input schema (status: enum['active','closed','all'], limit: number), description, name, and usage examples.export const listProjectsTool: ToolDefinition<ListProjectsArgs> = { name: "list_projects", description: "List GitHub projects", schema: listProjectsSchema as unknown as ToolSchema<ListProjectsArgs>, examples: [ { name: "List active projects", description: "List all active GitHub projects", args: { status: "active", limit: 5 } } ] };
- src/infrastructure/tools/ToolRegistry.ts:194-194 (registration)Registers the listProjectsTool in the central ToolRegistry singleton.this.registerTool(listProjectsTool);
- src/index.ts:262-263 (handler)MCP server dispatch handler that routes 'list_projects' tool calls to the ProjectManagementService.listProjects method.case "list_projects": return await this.service.listProjects(args.status, args.limit);
- Repository helper method that performs the actual GraphQL query to fetch projects from GitHub API and maps to domain models.async findAll(): Promise<Project[]> { const query = ` query($owner: String!, $repo: String!) { repository(owner: $owner, name: $repo) { projectsV2(first: 100) { nodes { id title shortDescription closed createdAt updatedAt } } } } `; const response = await this.graphql<ListProjectsResponse>(query, { owner: this.owner, repo: this.repo, }); return response.repository.projectsV2.nodes.map((project: GitHubProject) => ({ id: project.id, type: ResourceType.PROJECT, title: project.title, description: project.shortDescription || "", owner: this.owner, number: parseInt(project.id.split('_').pop() || '0'), url: `https://github.com/orgs/${this.owner}/projects/${parseInt(project.id.split('_').pop() || '0')}`, status: project.closed ? ResourceStatus.CLOSED : ResourceStatus.ACTIVE, visibility: "private", views: [], fields: [], createdAt: project.createdAt, updatedAt: project.updatedAt, closed: project.closed })); }