apply_prompt_unit_tests
Generate unit tests for code by providing a structured prompt, including optional specific instructions and version selection, integrated with Cursor IDE.
Instructions
Provides a prompt for generating unit tests for code
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code_to_test | Yes | The code that needs unit tests | |
| specific_instructions | No | Optional specific instructions to include in the prompt | |
| version | No | The version of the prompt template to use (e.g., '1.0.0', '1.1.0', or 'latest') |
Implementation Reference
- mcp_hitchcode/server.py:317-340 (handler)The core handler function that renders a 'test' prompt template using the provided code_to_test and returns it as TextContent.async def apply_prompt_unit_tests( code_to_test: str, specific_instructions: str = "", version: str = "latest", ) -> list[types.TextContent]: """ Provides a prompt for generating unit tests for code. Args: code_to_test: The code that needs unit tests. specific_instructions: Optional specific instructions to include in the prompt. version: The version of the prompt template to use. Defaults to "latest". Returns: A list containing a TextContent object with the prompt. """ # Render the prompt template with the code to test and specific instructions response_text = render_prompt_template( "test", version_str=version, code_to_test=code_to_test, specific_instructions=specific_instructions, ) return [types.TextContent(type="text", text=response_text)]
- mcp_hitchcode/server.py:725-746 (schema)The tool schema definition including input schema with required 'code_to_test' parameter.types.Tool( name="apply_prompt_unit_tests", description="Provides a prompt for generating unit tests for code", inputSchema={ "type": "object", "required": ["code_to_test"], "properties": { "code_to_test": { "type": "string", "description": "The code that needs unit tests", }, "specific_instructions": { "type": "string", "description": "Optional specific instructions to include in the prompt", }, "version": { "type": "string", "description": "The version of the prompt template to use (e.g., '1.0.0', '1.1.0', or 'latest')", }, }, }, ),
- mcp_hitchcode/server.py:510-523 (registration)The dispatch logic in the @app.call_tool() function that handles calls to 'apply_prompt_unit_tests' by validating arguments and invoking the handler.elif name == "apply_prompt_unit_tests": if "code_to_test" not in arguments: return [ types.TextContent( type="text", text="Error: Missing required argument 'code_to_test'", ) ] version = arguments.get("version", "latest") specific_instructions = arguments.get("specific_instructions", "") return await apply_prompt_unit_tests( code_to_test=arguments["code_to_test"], specific_instructions=specific_instructions, version=version,