pub struct SdkMcpTool {
pub name: String,
pub description: String,
pub input_schema: Value,
pub handler: SdkMcpToolHandler,
pub annotations: Option<ToolAnnotations>,
}Expand description
Definition of an in-process MCP tool.
Created via the tool() factory function. Can be customized with
with_annotations() before being passed to
create_sdk_mcp_server().
§Fields
name— Unique tool name (used by the model to invoke it).description— Human-readable description of what the tool does.input_schema— JSON Schema defining the tool’s input parameters.handler— Async function that executes the tool logic.annotations— Optional behavioral hints (read-only, destructive, etc.).
Fields§
§name: StringTool name exposed to Claude.
description: StringHuman-readable tool description.
input_schema: ValueJSON Schema for the tool arguments.
handler: SdkMcpToolHandlerAsync handler invoked for tool calls.
annotations: Option<ToolAnnotations>Optional behavior hints for the model/runtime.
Implementations§
Source§impl SdkMcpTool
impl SdkMcpTool
Sourcepub fn with_annotations(self, annotations: ToolAnnotations) -> Self
pub fn with_annotations(self, annotations: ToolAnnotations) -> Self
Adds behavioral annotations to this tool.
Annotations provide hints about the tool’s behavior (e.g., read-only, destructive, idempotent) to help with permission handling.
Returns self for method chaining.
§Example
use claude_code::{tool, ToolAnnotations};
use serde_json::{json, Value};
let tool = tool(
"read_status",
"Reads status",
json!({"type":"object"}),
|_args: Value| async move { Ok(json!({"content": []})) },
)
.with_annotations(ToolAnnotations {
read_only_hint: Some(true),
..Default::default()
});
assert!(tool.annotations.is_some());Trait Implementations§
Source§impl Clone for SdkMcpTool
impl Clone for SdkMcpTool
Source§fn clone(&self) -> SdkMcpTool
fn clone(&self) -> SdkMcpTool
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SdkMcpTool
impl !RefUnwindSafe for SdkMcpTool
impl Send for SdkMcpTool
impl Sync for SdkMcpTool
impl Unpin for SdkMcpTool
impl UnsafeUnpin for SdkMcpTool
impl !UnwindSafe for SdkMcpTool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more