Overview
Concrete tool for bridging MCP tool definitions into Eino BaseTool instances provided by the internal/einomcp package.
Description
ToolsFromDefinitions converts OpenAI-style function tool definitions into tool.BaseTool instances (mcpBridgeTool). Each bridge tool's InvokableRun extracts the tool-call ID via compose.GetToolCallID, delegates to runMCPToolInvocation → agent.ExecuteMCPToolForConversation using the conversation ID from a thread-safe ConversationHolder, records the execution ID via an ExecutionRecorder callback, and prefixes IsError results with ToolErrorPrefix so the model can self-correct. An optional ToolInvokeNotifyHolder fires an immediate tool-result notification for UI/pending cleanup.
Usage
- External MCP federation step 3 (tool discovery): external server manifests are converted to Eino tools here.
- First engagement / HITL execution: builtin tools are also bridged through this path.
Code Reference
Source Location
- Repository: CyberStrikeAI
- File: internal/einomcp/mcp_tools.go
- Lines: ExecutionRecorder L20, ToolErrorPrefix L24, ToolsFromDefinitions L29-59, toolInfoFromDefinition L61-84, mcpBridgeTool.InvokableRun L102-124, runMCPToolInvocation L127-188
Signature
type ExecutionRecorder func(executionID, toolCallID string)
const ToolErrorPrefix = "__CYBERSTRIKE_AI_TOOL_ERROR__\n"
func ToolsFromDefinitions(
ag *agent.Agent,
holder *ConversationHolder,
defs []agent.Tool,
rec ExecutionRecorder,
toolOutputChunk func(toolName, toolCallID, chunk string),
invokeNotify *ToolInvokeNotifyHolder,
einoAgentName string,
) ([]tool.BaseTool, error)
// ConversationHolder (internal/einomcp/holder.go)
type ConversationHolder struct{ ... }
func (h *ConversationHolder) Set(id string)
func (h *ConversationHolder) Get() string
Import
import "cyberstrike-ai/internal/einomcp"
I/O Contract
Inputs
| Name |
Type |
Required |
Description
|
| ag |
*agent.Agent |
Yes |
Agent for ExecuteMCPToolForConversation
|
| holder |
*ConversationHolder |
Yes |
Thread-safe conversation ID
|
| defs |
[]agent.Tool |
Yes |
OpenAI-style function definitions
|
| rec |
ExecutionRecorder |
No |
Execution ID callback
|
| invokeNotify |
*ToolInvokeNotifyHolder |
No |
Immediate tool_result push
|
Outputs
| Name |
Type |
Description
|
| returns |
[]tool.BaseTool, error |
Eino tools registered in agent
|
Usage Examples
Bridge External MCP Tools
holder := &einomcp.ConversationHolder{}
holder.Set(conversationID)
tools, err := einomcp.ToolsFromDefinitions(agent, holder, externalDefs,
func(execID, callID string) { recordExecution(execID, callID) },
nil, // no streaming chunk
nil, // no invoke notify
"recon-agent",
)
Related Pages
Implements Principle
Uses Heuristic
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.