MCPcopy Create free account
hub / github.com/AI45Lab/Code / list_tools

Method list_tools

core/src/mcp/client.rs:124–146  ·  view source on GitHub ↗

List available tools

(&self)

Source from the content-addressed store, hash-verified

122
123 /// List available tools
124 pub async fn list_tools(&self) -> Result<Vec<McpTool>> {
125 let request = JsonRpcRequest::new(self.next_id(), "tools/list", None);
126 let response = self.transport.request(request).await?;
127
128 if let Some(error) = response.error {
129 return Err(anyhow!(
130 "MCP list_tools error: {} ({})",
131 error.message,
132 error.code
133 ));
134 }
135
136 let result: ListToolsResult =
137 serde_json::from_value(response.result.ok_or_else(|| anyhow!("No result"))?)?;
138
139 // Cache tools
140 {
141 let mut tools = self.tools.write().await;
142 *tools = result.tools.clone();
143 }
144
145 Ok(result.tools)
146 }
147
148 /// Get cached tools
149 pub async fn get_cached_tools(&self) -> Vec<McpTool> {

Callers 1

do_connectMethod · 0.80

Calls 4

writeMethod · 0.80
next_idMethod · 0.45
requestMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected