Skip to main content
Glama
jankowtf

MCP Server Template for Cursor IDE

by jankowtf

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
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 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)]
  • 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')", }, }, }, ),
  • 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,

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