Skip to main content
Glama
Tiberriver256

Azure DevOps MCP Server

list_work_items

Retrieve work items from Azure DevOps projects using queries, filters, or saved queries to track tasks, bugs, and features.

Instructions

List work items in a project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdNoThe ID or name of the project (Default: MyProject)
organizationIdNoThe ID or name of the organization (Default: mycompany)
teamIdNoThe ID of the team
queryIdNoID of a saved work item query
wiqlNoWork Item Query Language (WIQL) query
topNoMaximum number of work items to return
skipNoNumber of work items to skip

Implementation Reference

  • The core handler function implementing the list_work_items tool. It queries Azure DevOps work items using WIQL or a saved query ID, applies pagination, retrieves details for specified fields, and handles errors.
    export async function listWorkItems(
      connection: WebApi,
      options: ListWorkItemsOptions,
    ): Promise<WorkItemType[]> {
      try {
        const witApi = await connection.getWorkItemTrackingApi();
        const { projectId, teamId, queryId, wiql } = options;
    
        let workItemRefs: WorkItemReference[] = [];
    
        if (queryId) {
          const teamContext: TeamContext = {
            project: projectId,
            team: teamId,
          };
          const queryResult = await witApi.queryById(queryId, teamContext);
          workItemRefs = queryResult.workItems || [];
        } else {
          const query = wiql || constructDefaultWiql(projectId, teamId);
          const teamContext: TeamContext = {
            project: projectId,
            team: teamId,
          };
          const queryResult = await witApi.queryByWiql({ query }, teamContext);
          workItemRefs = queryResult.workItems || [];
        }
    
        // Apply pagination in memory
        const { top = 200, skip } = options;
        if (skip !== undefined) {
          workItemRefs = workItemRefs.slice(skip);
        }
        if (top !== undefined) {
          workItemRefs = workItemRefs.slice(0, top);
        }
    
        const workItemIds = workItemRefs
          .map((ref) => ref.id)
          .filter((id): id is number => id !== undefined);
    
        if (workItemIds.length === 0) {
          return [];
        }
    
        const fields = [
          'System.Id',
          'System.Title',
          'System.State',
          'System.AssignedTo',
        ];
        const workItems = await witApi.getWorkItems(
          workItemIds,
          fields,
          undefined,
          undefined,
        );
    
        if (!workItems) {
          return [];
        }
    
        return workItems.filter((wi): wi is WorkItem => wi !== undefined);
      } catch (error) {
        if (error instanceof AzureDevOpsError) {
          throw error;
        }
    
        // Check for specific error types and convert to appropriate Azure DevOps errors
        if (error instanceof Error) {
          if (
            error.message.includes('Authentication') ||
            error.message.includes('Unauthorized')
          ) {
            throw new AzureDevOpsAuthenticationError(
              `Failed to authenticate: ${error.message}`,
            );
          }
    
          if (
            error.message.includes('not found') ||
            error.message.includes('does not exist')
          ) {
            throw new AzureDevOpsResourceNotFoundError(
              `Resource not found: ${error.message}`,
            );
          }
        }
    
        throw new AzureDevOpsError(
          `Failed to list work items: ${error instanceof Error ? error.message : String(error)}`,
        );
      }
    }
  • Zod schema defining the input validation for list_work_items tool parameters.
    export const ListWorkItemsSchema = z.object({
      projectId: z
        .string()
        .optional()
        .describe(`The ID or name of the project (Default: ${defaultProject})`),
      organizationId: z
        .string()
        .optional()
        .describe(`The ID or name of the organization (Default: ${defaultOrg})`),
      teamId: z.string().optional().describe('The ID of the team'),
      queryId: z.string().optional().describe('ID of a saved work item query'),
      wiql: z.string().optional().describe('Work Item Query Language (WIQL) query'),
      top: z.number().optional().describe('Maximum number of work items to return'),
      skip: z.number().optional().describe('Number of work items to skip'),
    });
  • Tool definition object registering the list_work_items tool with name, description, and JSON schema.
    {
      name: 'list_work_items',
      description: 'List work items in a project',
      inputSchema: zodToJsonSchema(ListWorkItemsSchema),
    },
  • Dispatch handler case for list_work_items that validates input with schema and invokes the handler function.
    case 'list_work_items': {
      const args = ListWorkItemsSchema.parse(request.params.arguments);
      const result = await listWorkItems(connection, {
        projectId: args.projectId ?? defaultProject,
        teamId: args.teamId,
        queryId: args.queryId,
        wiql: args.wiql,
        top: args.top,
        skip: args.skip,
      });
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
  • TypeScript interface defining options for the listWorkItems handler function, matching the schema.
    export interface ListWorkItemsOptions {
      projectId: string;
      teamId?: string;
      queryId?: string;
      wiql?: string;
      top?: number;
      skip?: number;
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It states 'List work items' but doesn't describe return format, pagination behavior, permissions required, rate limits, or whether it's read-only. For a tool with 7 parameters and no output schema, this leaves critical operational details unspecified, though it doesn't contradict any annotations.

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, clear sentence with zero wasted words. It's front-loaded with the core action and resource, making it immediately scannable. Every word earns its place by establishing the tool's fundamental purpose without unnecessary elaboration.

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

Completeness2/5

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

Given 7 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't address how results are returned, what authentication is needed, error conditions, or the interplay between filtering parameters. For a list operation with multiple filtering options, more context is needed to use it effectively.

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 parameters are fully documented in the schema. The description adds no additional parameter semantics beyond implying a project context. It doesn't explain relationships between parameters (e.g., projectId vs. organizationId) or usage patterns. This meets the baseline for high schema coverage but doesn't enhance understanding.

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 ('List') and resource ('work items in a project'), making the purpose immediately understandable. It distinguishes this tool from siblings like 'get_work_item' (singular retrieval) and 'search_work_items' (search-based filtering). However, it doesn't specify whether it lists all work items or uses default filtering, which prevents a perfect score.

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 like 'search_work_items' or 'get_work_item'. It mentions 'in a project' but doesn't clarify if this is required or how it relates to other parameters like organizationId or teamId. Without explicit when/when-not instructions, users must infer usage from parameter names 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