Skip to main content
Glama
kornbed

Jira MCP Server for Cursor

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);
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'search' implies a read operation, the description doesn't address important behavioral aspects like authentication requirements, rate limits, pagination behavior, error conditions, or what happens when no results are found. This is a significant gap 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 extremely concise - a single sentence that efficiently communicates the core functionality without any wasted words. It's front-loaded with the essential information and earns its place by clearly stating what the tool does.

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 search tool with 3 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what the search covers (titles, descriptions, comments?), how results are returned, what format they're in, or any limitations. The agent would need to guess about important operational details.

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?

The schema description coverage is 100%, so all parameters are documented in the schema. The description mentions 'text search' which aligns with the 'searchText' parameter and 'specific projects' which aligns with 'projectKeys', but adds no additional semantic context beyond what the schema already provides. This meets the baseline for high schema coverage.

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 tool's purpose: 'Search for tickets in specific projects using text search'. It specifies the verb ('search'), resource ('tickets'), and scope ('in specific projects'), but doesn't explicitly differentiate from sibling tools like 'list_tickets' or 'get_ticket', 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. It doesn't mention when this search tool is preferred over 'list_tickets' or 'get_ticket', nor does it specify prerequisites or exclusions. This leaves the agent without contextual usage information.

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/kornbed/jira-mcp-server'

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