Skip to content

Cursor crashes the server when getting prompts #215

@honungsburk

Description

@honungsburk

Cursor just recently added supports for prompts but when using the feature it crashes the MCP server. The problem appears to be that it does not include any parameters which fails a pattern match.

09:50:24.960 [error] GenServer {Hermes.Server.Registry, {:server, HeimdallMcp.Server}} terminating
** (FunctionClauseError) no function clause matching in Hermes.Server.Handlers.Prompts.handle_get/3
    (hermes_mcp 0.13.0) lib/hermes/server/handlers/prompts.ex:27: Hermes.Server.Handlers.Prompts.handle_get(%{"id" => 3, "jsonrpc" => "2.0", "method" => "prompts/get", "params" => %{"name" => "code_review"}}, #Frame<[session_id: "session_GFdGmorL7ByUlSi9TuY=", request: "prompts/get", assigns: %{}, initialized: true, tools: 0, resources: 17, prompts: 0]>, HeimdallMcp.Server)
    (hermes_mcp 0.13.0) lib/hermes/server/base.ex:503: Hermes.Server.Base.server_request/2
    (hermes_mcp 0.13.0) lib/hermes/server/base.ex:115: Hermes.Server.Base.handle_call/3
    (stdlib 6.2.2) gen_server.erl:2381: :gen_server.try_handle_call/4
    (stdlib 6.2.2) gen_server.erl:2410: :gen_server.handle_msg/6
    (stdlib 6.2.2) proc_lib.erl:340: :proc_lib.wake_up/3

interesting line is this:

Hermes.Server.Handlers.Prompts.handle_get(%{"id" => 3, "jsonrpc" => "2.0", "method" => "prompts/get", "params" => %{"name" => "code_review"}}, #Frame<[session_id: "session_GFdGmorL7ByUlSi9TuY=", request: "prompts/get", assigns: %{}, initialized: true, tools: 0, resources: 17, prompts: 0]>, HeimdallMcp.Server)

see "params" => %{"name" => "code_review"}

But the code requires an "arguments" key:

  @spec handle_get(map(), Frame.t(), module()) ::
          {:reply, map(), Frame.t()} | {:error, Error.t(), Frame.t()}
  def handle_get(%{"params" => %{"name" => prompt_name, "arguments" => params}}, frame, server) do
    registered_prompts = Handlers.get_server_prompts(server, frame)

    if prompt = find_prompt_module(registered_prompts, prompt_name) do
      with {:ok, params} <- validate_params(params, prompt, frame),
           do: forward_to(server, prompt, params, frame)
    else
      payload = %{message: "Prompt not found: #{prompt_name}"}
      {:error, Error.protocol(:invalid_params, payload), frame}
    end
  end

this is the prompt component I was trying to execute:

defmodule Heimdall.Prompt.CodeReview do
  @moduledoc "Prompt for reviewing the current git diff and performing a code review."

  use Hermes.Server.Component, type: :prompt

  alias Hermes.Server.Response

  schema do
  end

  @impl true
  def get_messages(_params, frame) do
    message = """
    You are an experienced code reviewer. Please review the current git diff and provide a thorough code review.

    ## Instructions:

    1. Run `git diff` to see the current changes
    2. Analyze the changes for:
       - Code quality and best practices
       - Potential bugs or issues
       - Security vulnerabilities
       - Performance implications
       - Code style and consistency
       - Documentation needs
       - Test coverage requirements
    3. Provide constructive feedback with:
       - Specific line references where applicable
       - Explanations for suggested improvements
       - Priority levels (critical, important, minor)
       - Actionable recommendations

    ## Review Format:

    ### Summary
    Brief overview of the changes and general assessment.

    ### Critical Issues
    Any blocking issues that must be addressed before merge.

    ### Important Suggestions
    Significant improvements that should be considered.

    ### Minor Improvements
    Optional enhancements for code quality.

    ### Positive Feedback
    What was done well in the changes.

    Please be thorough but constructive in your review.
    """

    response =
      Response.prompt("Code Review")
      |> Response.user_message(%{type: "text", text: message})

    {:reply, response, frame}
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions