Skip to main content
Glama
Tiberriver256

Azure DevOps MCP Server

get_work_item

Retrieve detailed information about a specific Azure DevOps work item using its ID, including fields, relations, and links for project tracking.

Instructions

Get details of a specific work item

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workItemIdYesThe ID of the work item
expandNoThe level of detail to include in the response. Defaults to "all" if not specified.

Implementation Reference

  • The core handler function that retrieves a work item by ID from Azure DevOps, fetches additional field definitions to enhance the response with all possible fields set to null if missing, and handles caching and errors.
    export async function getWorkItem(
      connection: WebApi,
      workItemId: number,
      expand: string = 'all',
    ): Promise<WorkItem> {
      try {
        const witApi = await connection.getWorkItemTrackingApi();
    
        const workItem = await witApi.getWorkItem(
          workItemId,
          undefined,
          undefined,
          expandMap[expand.toLowerCase()],
        );
    
        if (!workItem) {
          throw new AzureDevOpsResourceNotFoundError(
            `Work item '${workItemId}' not found`,
          );
        }
    
        // Extract project and work item type to get all possible fields
        const projectName = workItem.fields?.['System.TeamProject'];
        const workItemType = workItem.fields?.['System.WorkItemType'];
    
        if (!projectName || !workItemType) {
          // If we can't determine the project or type, return the original work item
          return workItem;
        }
    
        // Get all possible fields for this work item type
        const allFields =
          workItemTypeFieldsCache[projectName.toString()]?.[
            workItemType.toString()
          ] ??
          (await witApi.getWorkItemTypeFieldsWithReferences(
            projectName.toString(),
            workItemType.toString(),
            WorkItemTypeFieldsExpandLevel.All,
          ));
    
        workItemTypeFieldsCache[projectName.toString()] = {
          ...workItemTypeFieldsCache[projectName.toString()],
          [workItemType.toString()]: allFields,
        };
    
        // Create a new work item object with all fields
        const enhancedWorkItem = { ...workItem };
    
        // Initialize fields object if it doesn't exist
        if (!enhancedWorkItem.fields) {
          enhancedWorkItem.fields = {};
        }
    
        // Set null for all potential fields that don't have values
        for (const field of allFields) {
          if (
            field.referenceName &&
            !(field.referenceName in enhancedWorkItem.fields)
          ) {
            enhancedWorkItem.fields[field.referenceName] = field.defaultValue;
          }
        }
    
        return enhancedWorkItem;
      } catch (error) {
        if (error instanceof AzureDevOpsError) {
          throw error;
        }
        throw new Error(
          `Failed to get work item: ${error instanceof Error ? error.message : String(error)}`,
        );
      }
  • Zod schema for validating input arguments to the get_work_item tool: requires workItemId (number), optional expand (enum for expansion level).
    export const GetWorkItemSchema = z.object({
      workItemId: z.number().describe('The ID of the work item'),
      expand: z
        .enum(['none', 'relations', 'fields', 'links', 'all'])
        .optional()
        .describe(
          'The level of detail to include in the response. Defaults to "all" if not specified.',
        ),
    });
  • Tool registration definition including the tool name 'get_work_item', description, and input schema converted to JSON schema for MCP.
    {
      name: 'get_work_item',
      description: 'Get details of a specific work item',
      inputSchema: zodToJsonSchema(GetWorkItemSchema),
    },
  • Runtime dispatching/handling of the 'get_work_item' tool request: parses arguments with schema, calls the handler, and formats response.
    case 'get_work_item': {
      const args = GetWorkItemSchema.parse(request.params.arguments);
      const result = await getWorkItem(
        connection,
        args.workItemId,
        args.expand,
      );
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states it 'gets details', implying a read-only operation, but doesn't clarify aspects like authentication requirements, rate limits, error handling, or response format. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's front-loaded with the core purpose, making it easy to scan and understand quickly, which is ideal for conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks details on behavioral traits, usage context, and output expectations, leaving room for improvement in completeness for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters (workItemId and expand). The description doesn't add any meaning beyond what the schema provides, such as explaining the impact of different 'expand' values on the returned details. This meets the baseline score when schema coverage is high.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('details of a specific work item'), making the purpose evident. However, it doesn't explicitly differentiate from sibling tools like 'list_work_items' or 'search_work_items', which would require mentioning the singular vs. plural distinction or the need for a specific ID.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives such as 'list_work_items' or 'search_work_items'. It lacks context about prerequisites (e.g., needing a work item ID) or exclusions, leaving the agent to infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Tiberriver256/mcp-server-azure-devops'

If you have feedback or need assistance with the MCP directory API, please join our Discord server