Kuberwastaken/claurst · error

rmcp get_prompt ' ' failed

Error message

rmcp get_prompt '{}' failed: {}

What it means

Raised in `RmcpClientBackend::get_prompt` when the rmcp peer's `get_prompt(params)` future fails after building a `GetPromptRequestParams` (with optional string arguments) for the named prompt. This wraps transport failures and JSON-RPC error responses from the server's `prompts/get` handler. It does not cover prompt rendering failures reported inside a successful result — only failure of the protocol call itself.

Solutions

  1. Call list_prompts first and confirm the prompt name exists and matches exactly.
  2. Check the prompt's declared arguments and supply every required one with the correct name.
  3. Read the inner error text to distinguish 'unknown prompt' from validation and transport errors.
  4. Reconnect the session and retry if the transport was closed.

Example fix

// before: invoking by remembered name/args
let prompt = backend.get_prompt("review_code", None).await?;
// after: verify name and required arguments first
let prompts = backend.list_prompts().await?;
let p = prompts.iter().find(|p| p.name == "review_code")
    .ok_or_else(|| anyhow::anyhow!("prompt review_code not available"))?;
let mut args = HashMap::new();
for req in &p.required_arguments { args.insert(req.clone(), String::new()); }
let prompt = backend.get_prompt("review_code", Some(args)).await?;
Defensive patterns

Strategy: validation

Validate before calling

fn validate_prompt_args(prompts: &[McpPrompt], name: &str, args: &HashMap<String, String>) -> anyhow::Result<()> {
    let prompt = prompts.iter().find(|p| p.name == name)
        .ok_or_else(|| anyhow::anyhow!("prompt '{name}' not found"))?;
    for req in &prompt.required_arguments {
        anyhow::ensure!(args.contains_key(req), "prompt '{name}' requires argument '{req}'");
    }
    Ok(())
}

Try / catch

match backend.get_prompt(name, args).await {
    Ok(p) => p,
    Err(e) if e.to_string().contains("unknown prompt") => {
        eprintln!("prompt '{name}' not offered; refresh prompt list");
        GetPromptResult::default()
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `get_prompt(name, arguments)` when the request fails at protocol level: unknown prompt name (server returns 'unknown prompt'), missing required prompt arguments, argument values failing server validation, session closed mid-call, transport error, or timeout while the server renders the prompt.

Common situations: Using a slash command whose prompt was removed or renamed after a server update; invoking a prompt without its required arguments; wrong argument names that don't match the prompt's declared arguments; server-side template rendering error surfaced as a JSON-RPC error.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


AI-assisted analysis of Kuberwastaken/claurst@b0637c97ec (2026-09-10). Data as JSON: /api/errors/8d45a2ae09121792. Report an issue: GitHub.

Appendix: source

Thrown at src-rust/crates/mcp/src/rmcp_backend.rs:578

    async fn get_prompt(
        &self,
        name: &str,
        arguments: Option<HashMap<String, String>>,
    ) -> anyhow::Result<GetPromptResult> {
        let mut params = rmcp_model::GetPromptRequestParams::new(name.to_string());
        if let Some(arguments) = arguments {
            let args = arguments
                .into_iter()
                .map(|(key, value)| (key, Value::String(value)))
                .collect();
            params = params.with_arguments(args);
        }
        let result = self
            .peer
            .get_prompt(params)
            .await
            .map_err(|e| anyhow::anyhow!("rmcp get_prompt '{}' failed: {}", name, e))?;
        Ok(convert_get_prompt_result(result))
    }

    async fn subscribe_resource(&self, uri: &str) -> anyhow::Result<()> {
        self.peer
            .subscribe(rmcp_model::SubscribeRequestParams::new(uri.to_string()))
            .await
            .map_err(|e| anyhow::anyhow!("rmcp subscribe '{}' failed: {}", uri, e))
    }

    async fn unsubscribe_resource(&self, uri: &str) -> anyhow::Result<()> {
        self.peer
            .unsubscribe(rmcp_model::UnsubscribeRequestParams::new(uri.to_string()))
            .await
            .map_err(|e| anyhow::anyhow!("rmcp unsubscribe '{}' failed: {}", uri, e))
    }

    fn subscribe_to_notifications(&self) -> BoxStream<'static, anyhow::Result<Value>> {

View on GitHub (pinned to b0637c97ec)