get_available_projects
Retrieve available projects for a specified application in DevOps Plan systems to facilitate work item management and project organization.
Instructions
Get the list of projects in Plan for a given application
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| application | Yes | Name of the plan application |
Implementation Reference
- old-server.js:101-179 (handler)The implementation of the get_available_projects tool, which queries a Plan database for projects based on the provided application name.
server.tool( "get_available_projects", "Get the list of projects in Plan for a given application", { application: z.string().describe("Name of the plan application") }, async ({ application }) => { try { if (!globalCookies) { globalCookies = await getCookiesFromServer(serverURL); if (!globalCookies) { console.error("Failed to retrieve cookies from server."); return { error: "Failed to retrieve cookies." }; } console.log("Received Cookies:", globalCookies); } else { console.log("Reusing Stored Cookies:", globalCookies); } const queryPayload = { queryDef: { primaryEntityDefName: "Project", queryFieldDefs: [ { fieldPathName: "dbid", isShown: true, sortType: "SORT_DESC" }, { fieldPathName: "Name", isShown: true }, { fieldPathName: "DescriptionPT", isShown: true } ], filterNode: { boolOp: "BOOL_OP_AND", fieldFilters: [], childFilterNodes: [] } }, resultSetOptions: {} }; const queryResponse = await fetch(`${serverURL}/ccmweb/rest/repos/${teamspaceID}/databases/${application}/query`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Basic ${personal_access_token_string}`, 'Cookie': globalCookies }, body: JSON.stringify(queryPayload) }); const queryData = await queryResponse.json(); const resultSetId = queryData.result_set_id; if (!resultSetId) { throw new Error("Failed to retrieve result set ID"); } const projectsResponse = await fetch(`${serverURL}/ccmweb/rest/repos/${teamspaceID}/databases/${application}/query/${resultSetId}?pageNumber=1`, { method: 'GET', headers: { 'Content-Type': 'application/json', 'Authorization': `Basic ${personal_access_token_string}`, 'Cookie': globalCookies } }); const projectsData = await projectsResponse.json(); if (projectsData && projectsData.rows) { const projectNames = projectsData.rows.map(row => row.displayName); return { content: [{ type: 'text', text: `Projects retrieved: ${JSON.stringify(projectNames)}` }] }; } else { throw new Error("Failed to retrieve projects"); } } catch (e) { return { content: [{ type: 'text', text: `Error retrieving projects: ${e.message}` }] }; } } )