Skip to main content
Glama
kornbed

Jira MCP Server for Cursor

by kornbed

search_tickets

Search for Jira tickets in specified projects using text queries to find relevant issues quickly.

Instructions

Search for tickets in specific projects using text search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchTextYesThe text to search for in tickets
projectKeysYesComma-separated list of project keys
maxResultsNoMaximum number of results to return

Implementation Reference

  • The handler function for the 'search_tickets' tool. It validates Jira configuration, processes project keys, escapes the search text for JQL, performs a text search across specified projects, fetches issue details including descriptions, and formats the results.
      async ({ searchText, projectKeys, maxResults = 50 }: { searchText: string; projectKeys: string; maxResults?: number }) => {
        const configError = validateJiraConfig();
        if (configError) {
          return {
            content: [{ type: "text", text: `Configuration error: ${configError}` }],
          };
        }
    
        try {
          // Validate and format project keys
          const projects = validateAndFormatProjectKeys(projectKeys);
          if (projects.length === 0) {
            return {
              content: [{ type: "text", text: "No valid project keys provided. Please provide at least one project key." }],
            };
          }
    
          // Escape the search text for JQL
          const escapedText = escapeJQLText(searchText);
    
          // Construct the JQL query
          const jql = `text ~ "${escapedText}" AND project IN (${projects.join(',')}) ORDER BY updated DESC`;
    
          // Execute the search with description field included
          const searchResults = await jira.issueSearch.searchForIssuesUsingJql({
            jql,
            maxResults,
            fields: ['summary', 'status', 'updated', 'project', 'description'],
          });
    
          if (!searchResults.issues || searchResults.issues.length === 0) {
            return {
              content: [{ type: "text", text: `No tickets found matching "${searchText}" in projects: ${projects.join(', ')}` }],
            };
          }
    
          // Format the results with descriptions
          const formattedResults = searchResults.issues.map(issue => {
            const summary = issue.fields?.summary || 'No summary';
            const status = issue.fields?.status?.name || 'Unknown status';
            const project = issue.fields?.project?.key || 'Unknown project';
            const updated = issue.fields?.updated ? 
              new Date(issue.fields.updated).toLocaleString() :
              'Unknown date';
            const description = issue.fields?.description ? 
              extractTextFromADF(issue.fields.description) : 
              'No description';
            
            return `[${project}] ${issue.key}: ${summary}
    Status: ${status} (Updated: ${updated})
    Description:
    ${description.trim()}
    ----------------------------------------\n`;
          }).join('\n');
    
          const totalResults = searchResults.total || 0;
          const headerText = `Found ${totalResults} ticket${totalResults !== 1 ? 's' : ''} matching "${searchText}"\n\n`;
    
          return {
            content: [{ type: "text", text: headerText + formattedResults }],
          };
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
          return {
            content: [{ type: "text", text: `Failed to search tickets: ${errorMessage}` }],
          };
        }
      }
  • Input schema defined using Zod for the search_tickets tool parameters: searchText (required string), projectKeys (required string), maxResults (optional number).
    {
      searchText: z.string().describe("The text to search for in tickets"),
      projectKeys: z.string().describe("Comma-separated list of project keys"),
      maxResults: z.number().optional().describe("Maximum number of results to return"),
    },
  • src/server.ts:377-453 (registration)
    Registration of the 'search_tickets' MCP tool via server.tool(), specifying name, description, input schema, and inline handler function.
    server.tool(
      "search_tickets",
      "Search for tickets in specific projects using text search",
      {
        searchText: z.string().describe("The text to search for in tickets"),
        projectKeys: z.string().describe("Comma-separated list of project keys"),
        maxResults: z.number().optional().describe("Maximum number of results to return"),
      },
      async ({ searchText, projectKeys, maxResults = 50 }: { searchText: string; projectKeys: string; maxResults?: number }) => {
        const configError = validateJiraConfig();
        if (configError) {
          return {
            content: [{ type: "text", text: `Configuration error: ${configError}` }],
          };
        }
    
        try {
          // Validate and format project keys
          const projects = validateAndFormatProjectKeys(projectKeys);
          if (projects.length === 0) {
            return {
              content: [{ type: "text", text: "No valid project keys provided. Please provide at least one project key." }],
            };
          }
    
          // Escape the search text for JQL
          const escapedText = escapeJQLText(searchText);
    
          // Construct the JQL query
          const jql = `text ~ "${escapedText}" AND project IN (${projects.join(',')}) ORDER BY updated DESC`;
    
          // Execute the search with description field included
          const searchResults = await jira.issueSearch.searchForIssuesUsingJql({
            jql,
            maxResults,
            fields: ['summary', 'status', 'updated', 'project', 'description'],
          });
    
          if (!searchResults.issues || searchResults.issues.length === 0) {
            return {
              content: [{ type: "text", text: `No tickets found matching "${searchText}" in projects: ${projects.join(', ')}` }],
            };
          }
    
          // Format the results with descriptions
          const formattedResults = searchResults.issues.map(issue => {
            const summary = issue.fields?.summary || 'No summary';
            const status = issue.fields?.status?.name || 'Unknown status';
            const project = issue.fields?.project?.key || 'Unknown project';
            const updated = issue.fields?.updated ? 
              new Date(issue.fields.updated).toLocaleString() :
              'Unknown date';
            const description = issue.fields?.description ? 
              extractTextFromADF(issue.fields.description) : 
              'No description';
            
            return `[${project}] ${issue.key}: ${summary}
    Status: ${status} (Updated: ${updated})
    Description:
    ${description.trim()}
    ----------------------------------------\n`;
          }).join('\n');
    
          const totalResults = searchResults.total || 0;
          const headerText = `Found ${totalResults} ticket${totalResults !== 1 ? 's' : ''} matching "${searchText}"\n\n`;
    
          return {
            content: [{ type: "text", text: headerText + formattedResults }],
          };
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
          return {
            content: [{ type: "text", text: `Failed to search tickets: ${errorMessage}` }],
          };
        }
      }
    );
  • Helper function to escape special characters in the search text for safe inclusion in JQL queries.
    function escapeJQLText(text: string): string {
      // Escape special characters: + - & | ! ( ) { } [ ] ^ ~ * ? \ /
      return text.replace(/[+\-&|!(){}[\]^~*?\\\/]/g, '\\$&');
    }
  • Helper function to parse and validate comma-separated project keys, trimming and uppercasing them.
    function validateAndFormatProjectKeys(projectKeys: string): string[] {
      return projectKeys
        .split(',')
        .map(key => key.trim().toUpperCase())
        .filter(key => key.length > 0);
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.0.0

TDQS

B3.3/5.0
Behavior2/5

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

No annotations exist, so the description must fully disclose behavior. It lacks details on text matching (case sensitivity, wildcards), pagination beyond maxResults, and return format. The description is too brief for a search tool.

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, well-structured sentence that front-loads the action and purpose. No redundant or extraneous information.

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 no output schema and no annotations, the description provides basic intent but lacks details on search behavior, result structure, and edge cases. It is adequate but not comprehensive.

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 coverage is 100% with descriptions for all parameters. The tool description adds no additional meaning beyond what the schema already provides, so it meets the baseline of 3.

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

Purpose5/5

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

The description clearly states the action (search), resource (tickets), and scope (specific projects via projectKeys). It distinguishes from siblings like 'list_tickets' (no text search) and 'get_ticket' (single ticket).

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 on when to use this tool versus alternatives such as 'list_tickets' or 'get_project_issues'. Does not specify when not to use or provide criteria for selection.

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