get_available_components
Retrieve available components for a specific application and project in DevOps Plan to manage work items and project structure.
Instructions
Get the list of components for a project in Plan for a given application
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| application | Yes | Name of the application | |
| projectId | Yes | ID of the project |
Implementation Reference
- old-server.js:182-267 (handler)Implementation of the 'get_available_components' tool handler.
server.tool( "get_available_components", "Get the list of components for a project in Plan for a given application", { application: z.string().describe("Name of the application"), projectId: z.string().describe("ID of the project") }, async ({ application, projectId }) => { 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: "Component", queryFieldDefs: [ { fieldPathName: "Name", isShown: true, sortOrder: 0 }, { fieldPathName: "dbid", isShown: true, sortOrder: 0 }, { fieldPathName: "record_type", isShown: true, sortOrder: 0 } ], filterNode: { boolOp: "BOOL_OP_AND", fieldFilters: [], childFilterNodes: [] } }, resultSetOptions: { convertToLocalTime: false, maxResultSetRows: 10000, pageSize: 10000 } }; 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 componentsResponse = await fetch(`${serverURL}/ccmweb/rest/repos/${teamspaceID}/databases/${application}/query/${resultSetId}`, { method: 'GET', headers: { 'Content-Type': 'application/json', 'Authorization': `Basic ${personal_access_token_string}`, 'Cookie': globalCookies } }); const componentsData = await componentsResponse.json(); if (componentsData && componentsData.rows) { const componentNames = componentsData.rows.map(row => row.displayName); return { content: [{ type: 'text', text: `Components retrieved: ${JSON.stringify(componentNames)}` }] }; } else if( componentsData.length === 0) { return { content: [{ type: 'text', text: `Components retrieved: ${JSON.stringify("[]")}` }] }; } } catch (e) { return { content: [{ type: 'text', text: `Components retrieved: ${JSON.stringify("[]")}` }] }; } } )