#[non_exhaustive]pub struct Tool {
pub name: String,
pub namespaced_name: Option<String>,
pub description: String,
pub instructions: Option<String>,
pub parameters: HashMap<String, Value>,
pub overrides_built_in_tool: bool,
pub skip_permission: bool,
}Expand description
A tool that the client exposes to the Copilot agent.
Sent to the CLI as part of SessionConfig::tools / ResumeSessionConfig::tools
at session creation/resume time. The Rust SDK hand-authors this struct
(rather than using the schema-generated form) so it can carry runtime
hints — overrides_built_in_tool, skip_permission — that don’t appear
in the wire schema but are honored by the CLI.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringTool identifier (e.g., "bash", "grep", "str_replace_editor").
namespaced_name: Option<String>Optional namespaced name for declarative filtering (e.g., "playwright/navigate"
for MCP tools).
description: StringDescription of what the tool does.
instructions: Option<String>Optional instructions for how to use this tool effectively.
parameters: HashMap<String, Value>JSON Schema for the tool’s input parameters.
overrides_built_in_tool: boolWhen true, this tool replaces a built-in tool of the same name
(e.g. supplying a custom grep that the agent uses in place of the
CLI’s built-in implementation).
skip_permission: boolWhen true, the CLI does not request permission before invoking
this tool. Use with caution — the tool is responsible for any
access control.
Implementations§
Source§impl Tool
impl Tool
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Construct a new Tool with the given name and otherwise default
values. The struct is #[non_exhaustive], so external callers
cannot use struct-literal syntax — use this builder or
Default::default plus mut-let.
§Example
let tool = Tool::new("greet")
.with_description("Say hello to a user")
.with_parameters(json!({
"type": "object",
"properties": { "name": { "type": "string" } },
"required": ["name"]
}));Sourcepub fn with_namespaced_name(self, namespaced_name: impl Into<String>) -> Self
pub fn with_namespaced_name(self, namespaced_name: impl Into<String>) -> Self
Set the namespaced name for declarative filtering (e.g.
"playwright/navigate" for MCP tools).
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set the human-readable description of what the tool does.
Sourcepub fn with_instructions(self, instructions: impl Into<String>) -> Self
pub fn with_instructions(self, instructions: impl Into<String>) -> Self
Set optional instructions for how to use this tool effectively.
Sourcepub fn with_parameters(self, parameters: Value) -> Self
pub fn with_parameters(self, parameters: Value) -> Self
Set the JSON Schema for the tool’s input parameters.
Accepts anything that converts into a JSON object, including a
serde_json::Value produced by json!({...}). Non-object values
are stored as an empty parameter map; callers that need direct
control over the field can construct a HashMap<String, Value>
and assign it to Tool::parameters via Default::default.
Sourcepub fn with_overrides_built_in_tool(self, overrides: bool) -> Self
pub fn with_overrides_built_in_tool(self, overrides: bool) -> Self
Mark this tool as overriding a built-in tool of the same name.
E.g. supplying a custom grep that the agent uses in place of the
CLI’s built-in implementation.
Sourcepub fn with_skip_permission(self, skip: bool) -> Self
pub fn with_skip_permission(self, skip: bool) -> Self
When true, the CLI will not request permission before invoking
this tool. Use with caution — the tool is responsible for any
access control.