List Projects
list_projectsRetrieve a list of accessible Codebeamer projects, including IDs, names, and keys. Use project IDs to fetch trackers or items.
Instructions
List all Codebeamer projects the authenticated user can access. Returns a summary table with project IDs, names, and keys. Use the returned IDs to fetch trackers or items.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number (starts at 1) | |
| pageSize | No | Items per page (max 100) |
Implementation Reference
- src/tools/projects.ts:13-41 (handler)Registration of the 'list_projects' tool with McpServer. The handler calls client.listProjects() and formats the result via formatProjectList().
server.registerTool( "list_projects", { title: "List Projects", description: "List all Codebeamer projects the authenticated user can access. " + "Returns a summary table with project IDs, names, and keys. " + "Use the returned IDs to fetch trackers or items.", inputSchema: { page: z .number() .int() .min(1) .default(1) .describe("Page number (starts at 1)"), pageSize: z .number() .int() .min(1) .max(100) .default(25) .describe("Items per page (max 100)"), }, }, async ({ page, pageSize }) => { const result = await client.listProjects(page, pageSize); return { content: [{ type: "text", text: formatProjectList(result) }] }; }, ); - src/tools/projects.ts:21-35 (schema)Input schema for 'list_projects' using Zod: page (default 1, min 1) and pageSize (default 25, max 100).
inputSchema: { page: z .number() .int() .min(1) .default(1) .describe("Page number (starts at 1)"), pageSize: z .number() .int() .min(1) .max(100) .default(25) .describe("Items per page (max 100)"), }, - src/index.ts:38-38 (registration)Where registerProjectTools is called in the main entry point to set up the tool on the server.
registerProjectTools(server, client); - Client method listProjects() that makes an HTTP GET request to /projects and converts the response to an array of CbProject objects.
async listProjects(page: number, pageSize: number): Promise<CbProject[]> { const raw = await this.http.get<unknown>("/projects", { params: { page, pageSize }, resource: "projects", }); return toArray(raw); } - Formatting helper formatProjectList() that converts an array of CbProject objects into a markdown table string.
export function formatProjectList(projects: CbProject[]): string { const header = `## Projects (${projects.length} total)\n`; if (projects.length === 0) return `${header}\n_No projects found._`; const rows = projects.map( (p) => `| ${p.id} | ${p.name} | ${p.keyName ?? "-"} | ${p.closed ? "Closed" : "Open"} |`, ); return [ header, "| ID | Name | Key | Status |", "|----|------|-----|--------|", ...rows, ].join("\n"); }