mcp_text!() { /* proc-macro */ }
Expand description
Helper macro for creating MCP ContentBlock structures (advanced usage)
Note: Most tool functions should simply return String
using format!()
.
Only use mcp_text!()
when manually building CallToolResult structures.
§Common Usage (90% of cases) ✅
ⓘ
use turbomcp::prelude::*;
#[tool("Say hello")]
async fn hello(&self, name: String) -> turbomcp::McpResult<String> {
Ok(format!("Hello, {}!", name)) // ✅ Use format! for #[tool] returns
}
§Advanced Usage (rare) ⚠️
ⓘ
let name = "world";
let content_block = mcp_text!("Hello, {}!", name);
// Use in manual CallToolResult construction