Skip to main content
Glama
jankowtf

MCP Server Template for Cursor IDE

by jankowtf

apply_prompt_unit_tests

Generate unit test prompts for code by providing code snippets and optional instructions to create comprehensive test cases in Cursor IDE.

Instructions

Provides a prompt for generating unit tests for code

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
code_to_testYesThe code that needs unit tests
specific_instructionsNoOptional specific instructions to include in the prompt
versionNoThe version of the prompt template to use (e.g., '1.0.0', '1.1.0', or 'latest')

Implementation Reference

  • The core handler function for the 'apply_prompt_unit_tests' tool. It renders a prompt template named 'test' using the provided code_to_test, specific_instructions, and version, then returns the result 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)]
  • The input schema definition for the tool, specifying required 'code_to_test' parameter and optional 'specific_instructions' and 'version'.
    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')",
                },
            },
        },
    ),
  • The dispatch logic in the call_tool handler that routes requests for 'apply_prompt_unit_tests' to the corresponding function, including input validation.
    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,
        )

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/jankowtf/mcp-hitchcode'

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