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 to access execution data, suite hierarchy, and debug details.

Instructions

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

Input Schema

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

Implementation Reference

  • MCP tool handler: destructures args, fetches test case via client, parses with schema, renders Markdown, returns formatted JSON and Markdown content.
    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}` } ] }; }
  • src/index.ts:221-241 (registration)
    MCP server tool registration for 'get_test_case_by_key' with description, inline Zod input schema, and handler reference.
    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 schema defining input parameters for the get_test_case_by_key tool (case_key and project_key).
    export const GetTestCaseByKeySchema = z.object({ case_key: z.string().min(1), project_key: z.string().min(1) });
  • ZebrunnerClient helper method invoked by the tool handler to perform the API request for test case by key.
    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; }
  • Utility function to render fetched test case into user-friendly Markdown format, extracting and displaying steps, used in tool response.
    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");

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