Skip to main content
Glama
ennuiii

Azure DevOps MCP Server with PAT Authentication

by ennuiii

search_workitem

Search and filter Azure DevOps work items by text, project, area path, type, state, or assigned users using PAT authentication. Supports pagination and optional facet inclusion for detailed results.

Instructions

Get Azure DevOps Work Item search results for a given search text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
areaPathNoFilter by area paths
assignedToNoFilter by assigned to users
includeFacetsNoInclude facets in the search results
projectNoFilter by projects
searchTextYesSearch text to find in work items
skipNoNumber of results to skip for pagination
stateNoFilter by work item states
topNoNumber of results to return
workItemTypeNoFilter by work item types

Implementation Reference

  • The handler function for the 'search_workitem' tool. It constructs a search request to the Azure DevOps Work Item Search API, applies filters, fetches results, and returns them as text content.
    async ({ searchText, project, areaPath, workItemType, state, assignedTo, includeFacets, skip, top }) => {
      const accessToken = await tokenProvider();
      const url = `https://almsearch.dev.azure.com/${orgName}/_apis/search/workitemsearchresults?api-version=${apiVersion}`;
    
      const requestBody: Record<string, unknown> = {
        searchText,
        includeFacets,
        $skip: skip,
        $top: top,
      };
    
      const filters: Record<string, unknown> = {};
      if (project && project.length > 0) filters["System.TeamProject"] = project;
      if (areaPath && areaPath.length > 0) filters["System.AreaPath"] = areaPath;
      if (workItemType && workItemType.length > 0) filters["System.WorkItemType"] = workItemType;
      if (state && state.length > 0) filters["System.State"] = state;
      if (assignedTo && assignedTo.length > 0) filters["System.AssignedTo"] = assignedTo;
    
      if (Object.keys(filters).length > 0) {
        requestBody.filters = filters;
      }
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "Authorization": `Bearer ${accessToken.token}`,
          "User-Agent": userAgentProvider(),
        },
        body: JSON.stringify(requestBody),
      });
    
      if (!response.ok) {
        throw new Error(`Azure DevOps Work Item Search API error: ${response.status} ${response.statusText}`);
      }
    
      const result = await response.text();
      return {
        content: [{ type: "text", text: result }],
      };
    }
  • Zod schema defining the input parameters for the 'search_workitem' tool.
    {
      searchText: z.string().describe("Search text to find in work items"),
      project: z.array(z.string()).optional().describe("Filter by projects"),
      areaPath: z.array(z.string()).optional().describe("Filter by area paths"),
      workItemType: z.array(z.string()).optional().describe("Filter by work item types"),
      state: z.array(z.string()).optional().describe("Filter by work item states"),
      assignedTo: z.array(z.string()).optional().describe("Filter by assigned to users"),
      includeFacets: z.boolean().default(false).describe("Include facets in the search results"),
      skip: z.number().default(0).describe("Number of results to skip for pagination"),
      top: z.number().default(10).describe("Number of results to return"),
    },
  • Registers the 'search_workitem' tool on the MCP server using server.tool(), referencing SEARCH_TOOLS.search_workitem, providing description, input schema, and handler function.
    server.tool(
      SEARCH_TOOLS.search_workitem,
      "Get Azure DevOps Work Item search results for a given search text",
      {
        searchText: z.string().describe("Search text to find in work items"),
        project: z.array(z.string()).optional().describe("Filter by projects"),
        areaPath: z.array(z.string()).optional().describe("Filter by area paths"),
        workItemType: z.array(z.string()).optional().describe("Filter by work item types"),
        state: z.array(z.string()).optional().describe("Filter by work item states"),
        assignedTo: z.array(z.string()).optional().describe("Filter by assigned to users"),
        includeFacets: z.boolean().default(false).describe("Include facets in the search results"),
        skip: z.number().default(0).describe("Number of results to skip for pagination"),
        top: z.number().default(10).describe("Number of results to return"),
      },
      async ({ searchText, project, areaPath, workItemType, state, assignedTo, includeFacets, skip, top }) => {
        const accessToken = await tokenProvider();
        const url = `https://almsearch.dev.azure.com/${orgName}/_apis/search/workitemsearchresults?api-version=${apiVersion}`;
    
        const requestBody: Record<string, unknown> = {
          searchText,
          includeFacets,
          $skip: skip,
          $top: top,
        };
    
        const filters: Record<string, unknown> = {};
        if (project && project.length > 0) filters["System.TeamProject"] = project;
        if (areaPath && areaPath.length > 0) filters["System.AreaPath"] = areaPath;
        if (workItemType && workItemType.length > 0) filters["System.WorkItemType"] = workItemType;
        if (state && state.length > 0) filters["System.State"] = state;
        if (assignedTo && assignedTo.length > 0) filters["System.AssignedTo"] = assignedTo;
    
        if (Object.keys(filters).length > 0) {
          requestBody.filters = filters;
        }
    
        const response = await fetch(url, {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
            "Authorization": `Bearer ${accessToken.token}`,
            "User-Agent": userAgentProvider(),
          },
          body: JSON.stringify(requestBody),
        });
    
        if (!response.ok) {
          throw new Error(`Azure DevOps Work Item Search API error: ${response.status} ${response.statusText}`);
        }
    
        const result = await response.text();
        return {
          content: [{ type: "text", text: result }],
        };
      }
    );
  • Constant string identifier for the 'search_workitem' tool used in registration.
    search_workitem: "search_workitem",
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 states 'Get...search results' which implies a read-only operation, but doesn't disclose behavioral traits like pagination behavior (implied by skip/top parameters), authentication requirements, rate limits, error conditions, or what the return format looks like. The description is minimal and lacks essential context for safe invocation.

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 that states the core purpose without unnecessary words. It's appropriately sized for a search tool and front-loads the essential information. Every word earns its place.

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?

For a 9-parameter search tool with no annotations and no output schema, the description is inadequate. It doesn't explain what the search covers (fields searched), how results are returned, pagination behavior, or error handling. With rich parameter schema but no output information, the description should provide more context about the operation's behavior and results.

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 already documents all 9 parameters thoroughly. The description mentions only 'search text' (mapping to the required searchText parameter) but doesn't add any meaningful semantic context beyond what's in the schema. With high schema coverage, the baseline is 3 even without additional parameter information in the description.

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 ('Azure DevOps Work Item search results') with the key input ('search text'). It's specific about what the tool does but doesn't differentiate from sibling tools like 'search_code' or 'search_wiki' beyond mentioning 'Work Item'.

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. With many sibling tools like 'wit_get_work_item', 'wit_my_work_items', and 'wit_get_query_results_by_id', the description offers no context about when this search tool is preferable or what distinguishes it from other work item retrieval methods.

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

Related 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/ennuiii/DevOpsMcpPAT'

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