get_available_states
Retrieve available state transitions for work items in a DevOps Plan application to understand permissible workflow actions.
Instructions
Gets the state transition matrix for work items in Plan for a given application, showing available transitions/actions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| application | Yes | Name of the application |
Implementation Reference
- old-server.js:627-672 (handler)The registration and handler implementation of the "get_available_states" tool, which queries available states for work items via a REST API.
// Tool to get available states for work items server.tool( "get_available_states", "Gets the available states for work items in Plan for a given application", { application: z.string().describe("Name of the 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 response = await fetch(`${serverURL}/ccmweb/rest/repos/${teamspaceID}/databases/${application}/workspace/queryDefs/WorkItem/fieldOptions/state`, { method: 'GET', headers: { 'Content-Type': 'application/json', 'Authorization': `Basic ${personal_access_token_string}`, 'Cookie': globalCookies } }); if (!response.ok) { const errorText = await response.text(); throw new Error(`Failed to get available states with status ${response.status}: ${errorText}`); } const data = await response.json(); return { content: [{ type: 'text', text: `Available states: ${JSON.stringify(data)}` }] }; } catch (e) { return { content: [{ type: 'text', text: `Error retrieving available states: ${e.message}` }] }; } } );