list-projects
Retrieve and display all available projects from the Strateegia platform for project management and collaboration.
Instructions
List projects from Strateegia API
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:111-154 (handler)Handler logic for the 'list-projects' tool. Fetches project data from Strateegia API, processes labs and projects, and returns a formatted text response.if (request.params.name === "list-projects") { const labs: StrateegiaItemResponse[] = await fetchStrateegiaAPI( "/projects/v1/project" ); if (labs.length === 0) { return { content: [ { type: "text", text: "No labs found. Make sure your access token has the correct permissions.", }, ], }; } let labCount = 0; let projectCount = 0; const projectsSummary = labs .map((item) => { labCount++; projectCount += item.projects.length; return `Lab: ${item.lab.name} (ID: ${ item.lab.id })\nProjects:\n${item.projects .map((project) => { return `- ${project.title} (ID: ${project.id})`; }) .join("\n")}`; }) .join("\n\n"); const fullResponse = `Found ${labCount} labs and ${projectCount} projects:\n\n${projectsSummary}`; return { content: [ { type: "text", text: fullResponse, }, ], }; }
- src/index.ts:29-37 (schema)Tool definition including name, description, and input schema (empty object, no parameters required).const LIST_PROJECTS_TOOL: Tool = { name: "list-projects", description: "List projects from Strateegia API", inputSchema: { type: "object", properties: {}, required: [], }, };
- src/index.ts:106-108 (registration)Registers the 'list-projects' tool in the ListToolsRequest handler so it appears in tool lists.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [LIST_PROJECTS_TOOL], }));
- src/index.ts:86-103 (helper)Helper function to perform authenticated fetches to the Strateegia API, called by the list-projects handler.async function fetchStrateegiaAPI(endpoint: string): Promise<any> { const accessToken = await getAccessToken(); const response = await fetch(`${API_BASE_URL}${endpoint}`, { headers: { Authorization: `Bearer ${accessToken}`, "Content-Type": "application/json", }, }); if (!response.ok) { const errorText = await response.text(); throw new Error( `API request failed: ${response.status} ${response.statusText} - ${errorText}` ); } return response.json(); }
- src/index.ts:57-83 (helper)Helper function to obtain an access token using the STRATEEGIA_API_KEY environment variable, used by fetchStrateegiaAPI.async function getAccessToken(): Promise<string> { const api_key = process.env.STRATEEGIA_API_KEY; if (!api_key) { throw new Error("STRATEEGIA_API_KEY environment variable is not set"); } const options = { method: "POST", headers: { "x-api-key": api_key, }, }; async function fetchAccessToken() { const response = await fetch(API_AUTH_BASE, options); if (!response.ok) { const errorText = await response.text(); throw new Error( `API request failed: ${response.status} ${response.statusText} - ${errorText}` ); } return response.json(); } const token = await fetchAccessToken(); return token.access_token; }