testmo_create_case
Create a test case in Testmo with required fields (name, folder, priority, type, creator) and optional configs like template, state, tags, issues, and configurations.
Instructions
Create a single test case in Testmo.
Required fields in case_data:
name: Test case title
folder_id: Target folder ID (0 for root)
custom_priority: Priority ID (52=Critical, 1=High, 2=Medium, 3=Low)
custom_type: Type ID (59=Functional, 64=Acceptance, 55=Security)
custom_creator: Creator ID (51=AI Generated)
Optional fields:
template_id: 4=BDD/Gherkin (default), 1=Steps Table
state_id: 1=Draft, 2=Review, 3=Approved, 4=Active, 5=Deprecated
tags: Array of strings
issues: Array of issue objects for linking
configurations: Platform IDs array (4=Admin Portal, 5=iOS & Android, 10=Insti Web)
custom_milestone_id, custom_references, custom_feature, etc.
Args: project_id: The project ID. case_data: Test case data object with required fields.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| case_data | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- testmo/tools/cases.py:78-106 (handler)The `testmo_create_case` async function decorated with @mcp.tool(). Creates a single test case by sending a POST request to /projects/{project_id}/cases with the case_data wrapped in a 'cases' array. Returns the first created case from the result.
@mcp.tool() async def testmo_create_case(project_id: int, case_data: dict[str, Any]) -> dict[str, Any]: """Create a single test case in Testmo. Required fields in case_data: - name: Test case title - folder_id: Target folder ID (0 for root) - custom_priority: Priority ID (52=Critical, 1=High, 2=Medium, 3=Low) - custom_type: Type ID (59=Functional, 64=Acceptance, 55=Security) - custom_creator: Creator ID (51=AI Generated) Optional fields: - template_id: 4=BDD/Gherkin (default), 1=Steps Table - state_id: 1=Draft, 2=Review, 3=Approved, 4=Active, 5=Deprecated - tags: Array of strings - issues: Array of issue objects for linking - configurations: Platform IDs array (4=Admin Portal, 5=iOS & Android, 10=Insti Web) - custom_milestone_id, custom_references, custom_feature, etc. Args: project_id: The project ID. case_data: Test case data object with required fields. """ result = await _request( "POST", f"/projects/{project_id}/cases", data={"cases": [case_data]} ) cases = result.get("result", []) return cases[0] if cases else result - testmo/tools/cases.py:1-7 (registration)Imports the `mcp` FastMCP server instance from `..server` and the `_request` client helper. All tools in this module are registered via `@mcp.tool()` decorator.
import asyncio from typing import Any from ..server import mcp from ..client import _request from ..config import RATE_LIMIT_DELAY, MAX_CASES_PER_REQUEST - testmo/server.py:6-6 (registration)The FastMCP instance `mcp` is created here as `FastMCP('testmo-mcp')`. Used by all tool modules to register tools via the @mcp.tool() decorator.
mcp = FastMCP("testmo-mcp") - testmo/client.py:25-49 (helper)The `_request` async helper function used by testmo_create_case to make HTTP requests to the Testmo API. Handles authentication, error handling, and response parsing.
async def _request( method: str, endpoint: str, data: dict[str, Any] | None = None, params: dict[str, Any] | None = None, ) -> dict[str, Any]: async with _get_client() as client: response = await client.request( method=method, url=endpoint, json=data, params=params, ) if response.status_code == 204: return {"success": True} if response.status_code >= 400: try: error_body = response.json() except Exception: error_body = response.text raise RuntimeError( f"Testmo API error {response.status_code}: " f"{json.dumps(error_body) if isinstance(error_body, dict) else error_body}" ) return response.json() - testmo/config.py:14-91 (schema)FIELD_MAPPINGS dictionary containing the numeric IDs for custom fields (priority, type, creator, configurations, template_id, state_id, etc.) referenced in the testmo_create_case docstring for constructing case_data.
FIELD_MAPPINGS: dict[str, Any] = { "custom_priority": { "Critical": 52, "High": 1, "Medium": 2, "Low": 3, }, "custom_type": { "Performance": 57, "Functional": 59, "Usability": 53, "Acceptance": 64, "Compatibility": 61, "Security": 55, "Other": 58, }, "custom_creator": { "AI Generated": 51, }, "configurations": { "Admin Portal": 4, "IOS & Android": 5, "Insti Web": 10, }, "template_id": { "BDD/Gherkin": 4, "Steps Table": 1, }, "state_id": { "Draft": 1, "Review": 2, "Approved": 3, "Active": 4, "Deprecated": 5, }, "status_id": { "Incomplete": 1, "Complete": 2, }, "result_status_id": { "Untested": 1, "Passed": 2, "Failed": 3, "Retest": 4, "Blocked": 5, "Skipped": 6, }, "automation_run_status": { "Success": 2, "Failure": 3, "Running": 4, }, "custom_issues_tags_and_configurations_added": { "Yes": 66, "No": 67, }, "tags": { "domain": [ "assets-crypto", "assets-noncrypto", "services-usergrowth", "services-platform", "wealth-hnwi", ], "tier-type": ["ui-verification", "e2e", "negative"], "scope": ["regression", "smoke", "sanity"], "risk": ["risk-financial", "risk-security", "risk-compliance"], }, "defaults": { "template_id": 4, "state_id": 1, "status_id": 2, "custom_priority": 2, "custom_type": 59, "custom_creator": 51, "custom_issues_tags_and_configurations_added": 66, }, }