Skip to main content
Glama

get_test_case_by_key

Retrieve detailed test case information from Zebrunner Test Case Management using a specific case key, supporting multiple output formats for QA analysis.

Instructions

🔍 Get detailed test case by key (✅ Verified Working)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_keyNoProject key (e.g., 'android' or 'ANDROID') - auto-detected from case_key if not provided
case_keyYesTest case key (e.g., 'ANDROID-29', 'IOS-2')
formatNoOutput formatjson
include_debugNoInclude debug information in markdown
include_suite_hierarchyNoInclude featureSuiteId and rootSuiteId with suite hierarchy path
include_clickable_linksNoInclude clickable links to Zebrunner web UI

Implementation Reference

  • src/index.ts:221-240 (registration)
    Registration and inline handler implementation for the MCP tool 'get_test_case_by_key'. Fetches test case using ZebrunnerClient and returns formatted JSON and Markdown content.
    server.tool(
      "get_test_case_by_key",
      "Return detailed info of a test case by case_key and project_key (✅ Working). Also returns a Markdown export of steps.",
      {
        case_key: z.string().min(1),
        project_key: z.string().min(1)
      },
      async (args) => {
        const { case_key, project_key } = args;
        const tc = await client.getTestCaseByKey(case_key, project_key);
        const parsed = TestCaseDetailsSchema.safeParse(tc);
        const data = parsed.success ? parsed.data : tc;
        const md = renderTestCaseMarkdown(tc);
        return {
          content: [
            { type: "text", text: `**JSON Data:**\n\n\`\`\`json\n${JSON.stringify(data, null, 2)}\n\`\`\`` },
            { type: "text", text: `**Markdown Export:**\n\n${md}` }
          ]
        };
      }
  • Zod input schema for the 'get_test_case_by_key' tool defining required parameters case_key and project_key.
    export const GetTestCaseByKeySchema = z.object({
      case_key: z.string().min(1),
      project_key: z.string().min(1)
    });
  • Helper function to render test case details as Markdown, used by the tool handler for the Markdown export.
    function renderTestCaseMarkdown(tcRaw: any): string {
      const id = tcRaw?.id ?? "N/A";
      const key = tcRaw?.key ?? "N/A";
      const title = tcRaw?.title ?? "(no title)";
      const description = tcRaw?.description ?? "";
      const priority = tcRaw?.priority?.name ?? "N/A";
      const automationState = tcRaw?.automationState?.name ?? "N/A";
      const createdBy = tcRaw?.createdBy?.username ?? "N/A";
      const lastModifiedBy = tcRaw?.lastModifiedBy?.username ?? "N/A";
    
      const header = `# Test Case: ${title}\n\n- **ID:** ${id}\n- **Key:** ${key}\n- **Priority:** ${priority}\n- **Automation State:** ${automationState}\n- **Created By:** ${createdBy}\n- **Last Modified By:** ${lastModifiedBy}\n\n`;
      const descBlock = description ? `## Description\n\n${description}\n\n` : "";
      
      // Handle custom fields
      let customFieldsBlock = "";
      if (tcRaw?.customField && typeof tcRaw.customField === 'object') {
        const fields = Object.entries(tcRaw.customField)
          .filter(([key, value]) => value !== null && value !== undefined && value !== "")
          .map(([key, value]) => `- **${key}:** ${value}`)
          .join('\n');
        if (fields) {
          customFieldsBlock = `## Custom Fields\n\n${fields}\n\n`;
        }
      }
    
      const steps = Array.isArray(tcRaw?.steps) ? tcRaw.steps : [];
    
      if (!steps.length) {
        return `${header}${descBlock}${customFieldsBlock}## Steps\n\n_No explicit steps provided._\n`;
      }
    
      const lines: string[] = [];
      lines.push(`${header}${descBlock}${customFieldsBlock}## Steps\n`);
    
      const pick = (obj: any, keys: string[], fallback?: any) => {
        for (const k of keys) {
          if (obj && Object.prototype.hasOwnProperty.call(obj, k) && obj[k] != null) {
            return obj[k];
          }
        }
        return fallback;
      };
    
      steps.forEach((s: any, idx: number) => {
        const num = pick(s, ["stepNumber", "number", "index", "order"], idx + 1);
        const action = pick(s, ["action", "actual", "step", "actionText", "instruction", "name"]);
        const expected = pick(s, ["expected", "expectedResult", "expectedText", "result"]);
        const data = pick(s, ["data", "inputs", "parameters", "payload"]);
    
        lines.push(`### Step ${num}`);
        if (action) lines.push(`- **Action:** ${action}`);
        if (expected) lines.push(`- **Expected:** ${expected}`);
        if (data !== undefined) {
          if (typeof data === "object") {
            lines.push(`- **Data:**\n${codeBlockJson(data)}`);
          } else {
            lines.push(`- **Data:** ${String(data)}`);
          }
        }
        if (!action && !expected) {
          lines.push(`- **Raw step:**\n${codeBlockJson(s)}`);
        }
        lines.push("");
      });
    
      return lines.join("\n");
    }
  • ZebrunnerClient helper method that performs the actual API call to retrieve test case by key and project.
    async getTestCaseByKey(caseKey: string, projectKey: string): Promise<any> {
      const res = await this.http.get(`/test-cases/key:${caseKey}`, {
        params: { projectKey }
      });
      // API returns {data: {...}} structure for this endpoint
      return res.data?.data || res.data;
    }
  • Duplicate legacy registration and handler in enhanced index file for backward compatibility.
    "get_test_case_by_key",
    "Legacy: Return detailed info of a test case by case_key and project_key (✅ Working)",
    {
      case_key: z.string().min(1),
      project_key: z.string().min(1)
    },
    async (args) => {
      const { case_key, project_key } = args;
      try {
        const tc = await legacyClient.getTestCaseByKey(case_key, project_key);
        const parsed = TestCaseDetailsSchema.safeParse(tc);
        const data = parsed.success ? parsed.data : tc;
        const md = renderTestCaseMarkdown(tc);
        return {
          content: [
            { type: "text", text: `**JSON Data:**\n\n\`\`\`json\n${JSON.stringify(data, null, 2)}\n\`\`\`` },
            { type: "text", text: `**Markdown Export:**\n\n${md}` }
          ]
        };
      } catch (error: any) {
        return { 
          content: [{ 
            type: "text", 
            text: `Error: ${error.message}` 
          }] 
        };
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the tool is 'Verified Working', which hints at reliability, but fails to describe critical behaviors: whether it's a read-only operation, what happens if the key doesn't exist, authentication requirements, rate limits, or response format details. The description adds minimal value beyond the basic purpose.

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?

Extremely concise and front-loaded: the core purpose is stated in the first few words. The verification note is brief and doesn't distract. Every element earns its place with no wasted words or redundant 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?

For a read operation with 6 parameters and no output schema, the description is minimally adequate. It states what the tool does but lacks details about return values, error handling, or behavioral constraints. With no annotations and no output schema, more context would be helpful, but the high schema coverage partially compensates.

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 all 6 parameters. The description adds no additional parameter semantics beyond what's in the schema (e.g., no examples of case_key formats beyond what's implied, no explanation of when to use different formats). Baseline 3 is appropriate 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.

Purpose4/5

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

The description clearly states the action ('Get detailed test case') and resource ('by key'), making the purpose immediately understandable. It distinguishes from siblings like 'get_test_case_by_title' by specifying the key-based lookup. The emoji and verification note add flavor but don't detract from clarity.

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 explicit guidance on when to use this tool versus alternatives like 'get_test_case_by_title', 'get_test_case_by_filter', or 'get_test_cases_advanced'. The description implies it's for retrieving a single test case by its identifier, but lacks context about prerequisites, error conditions, or comparison with sibling tools.

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/maksimsarychau/mcp-zebrunner'

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