From cbe66373ccf9fcab05f79a2be9daa0bd0c949747 Mon Sep 17 00:00:00 2001 From: Allaun Silverfox <28494262+allaunthefox@users.noreply.github.com> Date: Tue, 26 May 2026 17:49:55 -0500 Subject: [PATCH] feat(runtime): source tools/list from Lean manifest env var when spec.tools empty --- .../rust/crates/runtime/src/mcp_server.rs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/1-Distributed-Systems/agents/claw/rust/crates/runtime/src/mcp_server.rs b/1-Distributed-Systems/agents/claw/rust/crates/runtime/src/mcp_server.rs index 4610ed41..63ef90b3 100644 --- a/1-Distributed-Systems/agents/claw/rust/crates/runtime/src/mcp_server.rs +++ b/1-Distributed-Systems/agents/claw/rust/crates/runtime/src/mcp_server.rs @@ -20,6 +20,7 @@ use tokio::io::{ stdin, stdout, AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader, Stdin, Stdout, }; +use crate::lean_mcp_manifest; use crate::mcp_stdio::{ JsonRpcError, JsonRpcId, JsonRpcRequest, JsonRpcResponse, McpInitializeResult, McpInitializeServerInfo, McpListToolsResult, McpTool, McpToolCallContent, McpToolCallParams, @@ -53,11 +54,28 @@ pub struct McpServerSpec { /// response. pub server_version: String, /// Tool descriptors returned for `tools/list`. + /// + /// If empty, the server will attempt to load the tool list from a Lean-owned + /// manifest via `CLAW_LEAN_MCP_MANIFEST_CMD`. pub tools: Vec, /// Handler invoked for `tools/call`. pub tool_handler: ToolCallHandler, } +impl McpServerSpec { + fn resolved_tools(&self) -> Vec { + if !self.tools.is_empty() { + return self.tools.clone(); + } + + match lean_mcp_manifest::tools_from_env() { + Ok(Some(tools)) => tools, + Ok(None) => Vec::new(), + Err(_) => Vec::new(), + } + } +} + /// Minimal MCP stdio server. /// /// The server runs a blocking read/dispatch/write loop over the current @@ -178,7 +196,7 @@ impl McpServer { fn handle_tools_list(&self, id: JsonRpcId) -> JsonRpcResponse { let result = McpListToolsResult { - tools: self.spec.tools.clone(), + tools: self.spec.resolved_tools(), next_cursor: None, }; JsonRpcResponse {