mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Expose MCP provenance to tool lifecycle extensions (#40976)
## What changed - Add optional `McpToolContext` metadata to `ToolStartInput`, exposing the model-visible MCP tool details and its source classification without exposing the executable client. - Classify MCP calls as connectors, configured servers, plugin servers, executor-selected plugins, or other registrations based on the prepared call. - Prepare each MCP call before notifying tool lifecycle contributors and reuse that same call for execution so the callback describes the call that runs. ## Testing - Cover host-owned connector calls and extension-owned Apps server calls, including their distinct provenance and executed tool names. GitOrigin-RevId: efd23f511b1045ffdd96349d621ad62365569b2b
This commit is contained in:
1 parent
daa3eaf10f
commit
21ff2e802c
10 files changed
+264
-3
No files matched your search
@@ -17,11 +17,13 @@ use crate::tools::context::ToolPayload;
|
||||
use crate::tools::context::boxed_tool_output;
|
||||
use crate::tools::flat_tool_name;
|
||||
use crate::tools::hook_names::HookToolName;
|
||||
use crate::tools::lifecycle::notify_tool_start;
|
||||
use crate::tools::registry::CoreToolRuntime;
|
||||
use crate::tools::registry::PostToolUsePayload;
|
||||
use crate::tools::registry::PreToolUsePayload;
|
||||
use crate::tools::registry::ToolExecutor;
|
||||
use crate::tools::registry::ToolTelemetryTags;
|
||||
use codex_extension_api::McpToolContext;
|
||||
use codex_mcp::ToolInfo;
|
||||
use codex_protocol::mcp::is_node_repl_backed_server;
|
||||
use codex_protocol::user_input::UserInput;
|
||||
@@ -171,6 +173,26 @@ impl McpHandler {
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let prepared_mcp_call = invocation
|
||||
.session
|
||||
.prepare_mcp_call(
|
||||
&self.tool_info.server_name,
|
||||
self.tool_info.tool.name.as_ref(),
|
||||
)
|
||||
.await;
|
||||
let mcp_tool = prepared_mcp_call.as_ref().map(|call| {
|
||||
McpToolContext::from_prepared_call(
|
||||
call,
|
||||
invocation
|
||||
.turn
|
||||
.config
|
||||
.mcp_servers
|
||||
.get()
|
||||
.get(call.server_name()),
|
||||
)
|
||||
});
|
||||
notify_tool_start(&invocation, mcp_tool.as_ref()).await;
|
||||
|
||||
let originating_item_id = invocation.originating_item_id().await;
|
||||
let ToolInvocation {
|
||||
session,
|
||||
@@ -200,6 +222,7 @@ impl McpHandler {
|
||||
call_id.clone(),
|
||||
originating_item_id,
|
||||
&self.tool_info,
|
||||
prepared_mcp_call,
|
||||
self.hook_tool_name(),
|
||||
tool_name,
|
||||
payload,
|
||||
|
||||
Reference in new issue
Block a user