MCPcopy Index your code
hub / github.com/AI45Lab/Code / web_search

Method web_search

sdk/python/src/lib.rs:2167–2200  ·  view source on GitHub ↗

Search the web using multiple search engines.

(&self, py: Python<'_>, params: PyWebSearchParams)

Source from the content-addressed store, hash-verified

2165
2166 /// Search the web using multiple search engines.
2167 fn web_search(&self, py: Python<'_>, params: PyWebSearchParams) -> PyResult<PyToolResult> {
2168 let session = self.inner.clone();
2169 let mut args = serde_json::json!({
2170 "query": params.query,
2171 });
2172 if let Some(ref engines) = params.engines {
2173 args["engines"] = serde_json::json!(engines);
2174 }
2175 if let Some(limit) = params.limit {
2176 args["limit"] = serde_json::json!(limit);
2177 }
2178 if let Some(timeout) = params.timeout {
2179 args["timeout"] = serde_json::json!(timeout);
2180 }
2181 if let Some(ref proxy) = params.proxy {
2182 args["proxy"] = serde_json::json!(proxy);
2183 }
2184 if let Some(ref format) = params.format {
2185 args["format"] = serde_json::json!(format);
2186 }
2187 let result = py
2188 .allow_threads(move || get_runtime().block_on(session.tool("web_search", args)))
2189 .map_err(|e| PyRuntimeError::new_err(format!("Tool execution failed: {e}")))?;
2190 Ok(PyToolResult {
2191 name: result.name,
2192 output: result.output,
2193 exit_code: result.exit_code,
2194 metadata_json: result.metadata.as_ref().map(serde_json::Value::to_string),
2195 error_kind_json: result
2196 .error_kind
2197 .as_ref()
2198 .and_then(|k| serde_json::to_string(k).ok()),
2199 })
2200 }
2201
2202 /// Execute a git command.
2203 ///

Callers

nothing calls this directly

Calls 4

block_onMethod · 0.80
get_runtimeFunction · 0.70
cloneMethod · 0.45
toolMethod · 0.45

Tested by

no test coverage detected