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

Method execute_raw_with_context

core/src/tools/registry.rs:254–279  ·  view source on GitHub ↗

Execute a tool and return raw output with an external context

(
        &self,
        name: &str,
        args: &serde_json::Value,
        ctx: &ToolContext,
    )

Source from the content-addressed store, hash-verified

252
253 /// Execute a tool and return raw output with an external context
254 pub async fn execute_raw_with_context(
255 &self,
256 name: &str,
257 args: &serde_json::Value,
258 ctx: &ToolContext,
259 ) -> Result<Option<ToolOutput>> {
260 let tool = self.get(name);
261
262 match tool {
263 Some(tool) => {
264 let mut output = tool.execute(args, ctx).await?;
265 let original_content = output.content.clone();
266 let truncated = truncate_tool_output_with_artifact(name, &output.content);
267 output.content = truncated.content;
268 if let Some(artifact) = truncated.artifact {
269 self.store_tool_artifact(name, &original_content, &artifact);
270 output.metadata = Some(merge_tool_output_artifact_metadata(
271 output.metadata,
272 &artifact,
273 ));
274 }
275 Ok(Some(output))
276 }
277 None => Ok(None),
278 }
279 }
280
281 fn store_tool_artifact(&self, tool_name: &str, content: &str, artifact: &ToolOutputArtifact) {
282 self.artifact_store.put(ToolArtifact {

Callers 1

execute_rawMethod · 0.80

Calls 6

store_tool_artifactMethod · 0.80
getMethod · 0.45
executeMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected