Skip to main content
Glama
jankowtf

MCP Server Template for Cursor IDE

by jankowtf

apply_prompt_change

Generate structured prompts to implement change requests in Cursor IDE, providing systematic guidance for code modifications.

Instructions

Provides a prompt for systematically handling change requests

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
change_requestYesDescription of the change request to implement
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 executes the tool logic: renders the 'change' prompt template using render_prompt_template with the provided change_request and optional parameters, then returns it as MCP TextContent.
    async def apply_prompt_change(
        change_request: str,
        specific_instructions: str = "",
        version: str = "latest",
    ) -> list[types.TextContent]:
        """
        Provides a prompt for systematically handling change requests.
    
        Args:
            change_request: Description of the change request to implement.
            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 change request and specific instructions
        response_text = render_prompt_template(
            "change",
            version_str=version,
            change_request=change_request,
            specific_instructions=specific_instructions,
        )
        return [types.TextContent(type="text", text=response_text)]
  • The input schema definition for the apply_prompt_change tool, registered in the list_tools handler. Defines required 'change_request' and optional 'specific_instructions' and 'version' parameters.
    types.Tool(
        name="apply_prompt_change",
        description="Provides a prompt for systematically handling change requests",
        inputSchema={
            "type": "object",
            "required": ["change_request"],
            "properties": {
                "change_request": {
                    "type": "string",
                    "description": "Description of the change request to implement",
                },
                "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 registration and dispatching logic within the @app.call_tool() handler that checks arguments and invokes the apply_prompt_change handler function.
    elif name == "apply_prompt_change":
        if "change_request" not in arguments:
            return [
                types.TextContent(
                    type="text",
                    text="Error: Missing required argument 'change_request'",
                )
            ]
        version = arguments.get("version", "latest")
        specific_instructions = arguments.get("specific_instructions", "")
        return await apply_prompt_change(
            change_request=arguments["change_request"],
            specific_instructions=specific_instructions,
            version=version,
        )
  • The supporting utility function called by the handler to load, resolve version, parse metadata, and render the Jinja2 prompt template from prompts/change/*.md files.
    def render_prompt_template(
        template_name: str, version_str: str = "latest", **kwargs: Any
    ) -> str:
        """
        Render a prompt template with the given variables.
    
        Args:
            template_name: The name of the prompt template.
            version_str: The version of the template to use. Defaults to "latest".
            **kwargs: The variables to pass to the template.
    
        Returns:
            str: The rendered prompt template.
    
        Raises:
            FileNotFoundError: If the template file does not exist.
            jinja2.exceptions.TemplateError: If there is an error rendering the template.
            ValueError: If the specified version does not exist.
        """
        _build_version_registry()
    
        # Check if the template exists
        if template_name not in _version_registry:
            raise FileNotFoundError(f"Template not found: {template_name}")
    
        # Resolve the version
        if version_str == "latest":
            version_str = _version_registry[template_name].get("latest")
            if not version_str:
                raise ValueError(f"No versions found for template: {template_name}")
        elif version_str not in _version_registry[template_name]:
            # Try to find the closest version
            available_versions = get_template_versions(template_name)
            if not available_versions:
                raise ValueError(f"No versions found for template: {template_name}")
    
            # Find the highest version that is less than or equal to the requested version
            requested_ver = version.parse(version_str)
            for v in available_versions:
                if version.parse(v) <= requested_ver:
                    version_str = v
                    break
            else:
                # If no suitable version is found, use the oldest version
                version_str = available_versions[-1]
    
        # Get the filename from the registry
        filename = _version_registry[template_name][version_str]
    
        # Build the template path
        template_path = f"prompts/{template_name}/{filename}"
    
        # Load the template content
        content = load_template(template_path)
    
        # Parse the metadata and template content
        metadata, template_content = _parse_template_metadata(content)
    
        # Create a new template with just the content (without the front matter)
        env = get_template_env()
        template = env.from_string(template_content)
    
        # Render the template
        return template.render(**kwargs)

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