MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / execute

Method execute

crates/opencode-tool/src/todo.rs:52–97  ·  view source on GitHub ↗
(
        &self,
        args: serde_json::Value,
        ctx: ToolContext,
    )

Source from the content-addressed store, hash-verified

50 }
51
52 async fn execute(
53 &self,
54 args: serde_json::Value,
55 ctx: ToolContext,
56 ) -> Result<ToolResult, ToolError> {
57 let input: TodoReadInput =
58 serde_json::from_value(args).map_err(|e| ToolError::InvalidArguments(e.to_string()))?;
59
60 let session_id = input
61 .session_id
62 .clone()
63 .unwrap_or_else(|| ctx.session_id.clone());
64
65 ctx.ask_permission(
66 crate::PermissionRequest::new("todoread")
67 .with_metadata("session_id", serde_json::json!(&session_id))
68 .always_allow(),
69 )
70 .await?;
71
72 let todos = ctx.do_todo_get().await?;
73
74 let output = format_todos_from_data(&todos);
75
76 let todos_json: Vec<serde_json::Value> = todos
77 .iter()
78 .map(|t| {
79 serde_json::json!({
80 "content": t.content,
81 "status": t.status,
82 "priority": t.priority
83 })
84 })
85 .collect();
86
87 let mut metadata = std::collections::HashMap::new();
88 metadata.insert("todos".to_string(), serde_json::json!(todos_json));
89 metadata.insert("count".to_string(), serde_json::json!(todos.len()));
90
91 Ok(ToolResult {
92 title: format!("Todo List ({} items)", todos.len()),
93 output,
94 metadata,
95 truncated: false,
96 })
97 }
98}
99
100#[async_trait]

Callers

nothing calls this directly

Calls 8

newFunction · 0.85
format_todos_from_dataFunction · 0.85
ask_permissionMethod · 0.80
always_allowMethod · 0.80
with_metadataMethod · 0.80
do_todo_getMethod · 0.80
do_todo_updateMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected