Skip to main content
Glama

get-work-items

Retrieve Azure DevOps work items using WIQL queries, specific IDs, or custom fields to track and manage development tasks across projects.

Instructions

Get work items from Azure DevOps

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
wiqlNoWork Item Query Language (WIQL) query
idsNoSpecific work item IDs to retrieve
fieldsNoFields to include in the response

Implementation Reference

  • The core handler function that executes the 'get-work-items' tool logic. Supports WIQL queries, specific IDs, or default recent work items from the project using Azure DevOps Work Item Tracking API.
    private async getWorkItems(args: any): Promise<any> {
      try {
        let result;
        
        if (args.wiql) {
          // Query using WIQL
          const wiqlResult = await this.makeApiRequest('/wit/wiql?api-version=7.1', 'POST', {
            query: args.wiql
          });
          
          if (wiqlResult.workItems && wiqlResult.workItems.length > 0) {
            const ids = wiqlResult.workItems.map((wi: any) => wi.id);
            const fields = args.fields ? args.fields.join(',') : undefined;
            const fieldsParam = fields ? `&fields=${encodeURIComponent(fields)}` : '';
            
            result = await this.makeApiRequest(
              `/wit/workitems?ids=${ids.join(',')}${fieldsParam}&api-version=7.1`
            );
          } else {
            result = { value: [] };
          }
        } else if (args.ids && args.ids.length > 0) {
          // Get specific work items by ID
          const fields = args.fields ? args.fields.join(',') : undefined;
          const fieldsParam = fields ? `&fields=${encodeURIComponent(fields)}` : '';
          
          result = await this.makeApiRequest(
            `/wit/workitems?ids=${args.ids.join(',')}${fieldsParam}&api-version=7.1`
          );
        } else {
          // Default query for recent work items
          const defaultWiql = `SELECT [System.Id], [System.Title], [System.State], [System.AssignedTo] FROM WorkItems WHERE [System.TeamProject] = '${this.currentConfig!.project}' ORDER BY [System.ChangedDate] DESC`;
          
          const wiqlResult = await this.makeApiRequest('/wit/wiql?api-version=7.1', 'POST', {
            query: defaultWiql
          });
          
          if (wiqlResult.workItems && wiqlResult.workItems.length > 0) {
            const ids = wiqlResult.workItems.slice(0, 20).map((wi: any) => wi.id); // Limit to 20 items
            result = await this.makeApiRequest(
              `/wit/workitems?ids=${ids.join(',')}&api-version=7.1`
            );
          } else {
            result = { value: [] };
          }
        }
    
        return {
          content: [{
            type: 'text',
            text: JSON.stringify(result, null, 2),
          }],
        };
      } catch (error) {
        throw new Error(`Failed to get work items: ${error instanceof Error ? error.message : 'Unknown error'}`);
      }
    }
  • Defines the input schema, description, and name for the 'get-work-items' tool, used in the MCP listTools response.
    {
      name: 'get-work-items',
      description: 'Get work items from Azure DevOps',
      inputSchema: {
        type: 'object',
        properties: {
          wiql: {
            type: 'string',
            description: 'Work Item Query Language (WIQL) query',
          },
          ids: {
            type: 'array',
            items: { type: 'number' },
            description: 'Specific work item IDs to retrieve',
          },
          fields: {
            type: 'array',
            items: { type: 'string' },
            description: 'Fields to include in the response',
          },
        },
      },
    },
  • The switch statement in handleToolCall that registers and dispatches 'get-work-items' to its handler function.
    switch (name) {
      case 'get-work-items':
        return await this.getWorkItems(args || {});
      case 'create-work-item':
        return await this.createWorkItem(args || {});
      case 'update-work-item':
        return await this.updateWorkItem(args || {});
      case 'add-work-item-comment':
        return await this.addWorkItemComment(args || {});
      case 'get-repositories':
        return await this.getRepositories(args || {});
      case 'get-builds':
        return await this.getBuilds(args || {});
      case 'get-pull-requests':
        return await this.getPullRequests(args || {});
      case 'trigger-pipeline':
        return await this.triggerPipeline(args || {});
      case 'get-pipeline-status':
        return await this.getPipelineStatus(args || {});
      default:
        throw new Error(`Unknown tool: ${name}`);
    }
  • Supporting utility method for making authenticated HTTPS requests to Azure DevOps APIs, heavily used by the get-work-items handler.
    private async makeApiRequest(endpoint: string, method: string = 'GET', body?: any): Promise<any> {
      if (!this.currentConfig) {
        throw new Error('No configuration available');
      }
    
      const { organizationUrl, pat, project } = this.currentConfig;
      const baseUrl = `${organizationUrl}/${project}/_apis`;
      const requestUrl = `${baseUrl}${endpoint}`;
      
      return new Promise((resolve, reject) => {
        const urlParts = new url.URL(requestUrl);
        const postData = body ? JSON.stringify(body) : undefined;
        
        const options = {
          hostname: urlParts.hostname,
          port: urlParts.port || 443,
          path: urlParts.pathname + urlParts.search,
          method,
          headers: {
            'Authorization': `Basic ${Buffer.from(`:${pat}`).toString('base64')}`,
            'Content-Type': method === 'PATCH' && endpoint.includes('/wit/workitems/')
              ? 'application/json-patch+json'
              : 'application/json',
            'Accept': 'application/json',
            // For preview APIs, we need to properly handle the API version in the URL, not headers
            ...(postData && { 'Content-Length': Buffer.byteLength(postData) }),
          },
        };
    
        const req = https.request(options, (res) => {
          let data = '';
          
          res.on('data', (chunk) => {
            data += chunk;
          });
          
          res.on('end', () => {
            try {
              if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
                const result = data ? JSON.parse(data) : {};
                resolve(result);
              } else {
                reject(new Error(`HTTP ${res.statusCode}: ${data}`));
              }
            } catch (error) {
              reject(new Error(`Failed to parse response: ${error}`));
            }
          });
        });
    
        req.on('error', (error) => {
          reject(new Error(`Request failed: ${error.message}`));
        });
    
        if (postData) {
          req.write(postData);
        }
        
        req.end();
      });
    }
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. It only states the action without disclosing behavioral traits such as whether it's read-only, requires authentication, has rate limits, returns paginated results, or handles errors. For a tool with 3 parameters and no annotations, this is a significant gap in transparency.

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

Conciseness4/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 appropriately sized for a simple tool, though it could be more front-loaded with key details. It earns its place but lacks depth.

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 the tool's complexity (3 parameters, no annotations, no output schema), the description is incomplete. It doesn't cover return values, error handling, or behavioral context, leaving gaps for an AI agent to understand how to invoke it correctly. It should do more to compensate for the lack of structured data.

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 parameters (wiql, ids, fields). The description adds no meaning beyond this, as it doesn't explain how parameters interact (e.g., wiql vs ids) or provide usage examples. Baseline is 3 since the schema does the heavy lifting.

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

Purpose3/5

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

The description states the basic action ('Get work items') and source ('from Azure DevOps'), which provides a general purpose. However, it lacks specificity about what 'get' entails (e.g., list, retrieve, query) and doesn't distinguish it from siblings like 'create-work-item' or 'update-work-item' beyond the verb difference. It's vague but not tautological.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention scenarios like querying with WIQL versus retrieving by IDs, or how it differs from other get-* tools (e.g., 'get-builds', 'get-pull-requests'). The description offers no context for selection, leaving usage unclear.

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/wangkanai/devops-enhanced-mcp'

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