Skip to main content
Glama

Generate Code for Test Case

generate_code_for_test_case

Generate automation test code for a specific test case. Call get_test_capabilities first and use its recommendation unless evidence favors an override; then execute the result and continue its autonomous QA loop. Supports Playwright, pytest, Cypress, Selenium, Vitest, Jest, Kotlin, Scala, Go (go test), and Rust (cargo test). When framework is omitted, the framework is auto-resolved from project settings, linked-repository language detection, and the test category.

For a test case in a Native Mobile project, pass framework: "appium" together with platform ('android' or 'ios'). That is a different lane: the test case's steps are compiled deterministically into a managed native script (no AI generation, no coding-seat job, so it answers inline), and the response is compact metadata rather than code. Run the resulting script_id with run_tests — not run_native_test, which is for Go/Rust/Jest only. Generic frameworks will produce browser-oriented code for a native case.

Input Schema

NameRequiredDescriptionDefault
contextNoExplain why you are calling this tool and how it fits into the user's overall goal. This parameter is used for analytics and user intent tracking. YOU MUST provide 15-25 words (count carefully). NEVER use first person ('I', 'we', 'you') - maintain third-person perspective. NEVER include sensitive information such as credentials, passwords, or personal data. Example (20 words): "Searching across the organization's repositories to find all open issues related to performance complaints and latency issues for team prioritization."
platformNoNative mobile platform for `framework: "appium"`. Required when the project has both an Android and an iOS app connected; otherwise it defaults to the single connected platform. Rejected for every other framework.
frameworkNoOptional framework override. One of: playwright, pytest, cypress, selenium, jest, vitest, kotlin, scala, go, rust, appium. Use 'appium' for a native mobile test case, and pass `platform` with it. When omitted, the framework is auto-detected from the linked repository or test category — auto-detection never selects appium.
test_case_idYesTest case ID to generate code for
generation_serviceNoCode-generation service; auto uses the project settingauto

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.3/5.0
Behavior4/5

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

Annotations only say readOnlyHint=false and openWorldHint=true; the description adds real behavioral detail beyond them: the appium path is compiled deterministically with no AI generation, runs no coding-seat job, answers inline, and returns compact metadata rather than code, while generic frameworks produce browser-oriented code for native cases. It doesn't disclose how the main AI-generation lane behaves in terms of latency, async job submission, or side effects, which keeps it from a 5.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose and the most important routing constraint, then organized into a separate native-mobile paragraph. It is slightly verbose: the framework list and appium/platform rules are duplicated between the description and the enum descriptions, so a bit of text could be trimmed.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a non-read-only, open-world mutation tool with no output schema, the description covers the workflow (capabilities lookup first, execute after) and the return type for the appium lane. It never states what the primary AI-generation lane returns (raw code, a script ID, or an async job reference), which leaves a real gap for the main path.

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% and the schema descriptions already cover framework auto-detection never selecting appium, platform being required for dual-platform projects, and platform being rejected for other frameworks. The description restates these relationships in narrative form rather than adding new parameter semantics, so the baseline of 3 applies.

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?

States a specific verb+resource ('Generate automation test code for a specific test case') and immediately distinguishes itself from siblings by naming get_test_capabilities, run_tests, and run_native_test. The native-appium lane is explicitly carved out as a different mode, so an agent can tell what this tool does and does not do without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives an explicit call-order prerequisite ('Call get_test_capabilities first and use its recommendation unless evidence favors an override') and an explicit next step ('execute the result and continue its autonomous QA loop'). It also names the exact alternative to avoid in the native case ('Run the resulting script_id with run_tests — not run_native_test').

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources