NewWorkspaceMCPTool creates a tool wrapper from an MCPToolInfo discovered on a workspace agent. Each tool proxies calls back through the agent connection. The optional invalidateCache callback is invoked when CallMCPTool returns a 404 error, indicating that the server was removed and the chat's cach
( tool workspacesdk.MCPToolInfo, getConn func(context.Context) (workspacesdk.AgentConn, error), invalidateCache func(), )
| 32 | // indicating that the server was removed and the chat's cached |
| 33 | // tool list should be dropped. |
| 34 | func NewWorkspaceMCPTool( |
| 35 | tool workspacesdk.MCPToolInfo, |
| 36 | getConn func(context.Context) (workspacesdk.AgentConn, error), |
| 37 | invalidateCache func(), |
| 38 | ) *WorkspaceMCPTool { |
| 39 | required := tool.Required |
| 40 | if required == nil { |
| 41 | required = []string{} |
| 42 | } |
| 43 | return &WorkspaceMCPTool{ |
| 44 | info: fantasy.ToolInfo{ |
| 45 | Name: tool.Name, |
| 46 | Description: tool.Description, |
| 47 | Parameters: tool.Schema, |
| 48 | Required: required, |
| 49 | Parallel: true, |
| 50 | }, |
| 51 | getConn: getConn, |
| 52 | invalidateCache: invalidateCache, |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | func (t *WorkspaceMCPTool) Info() fantasy.ToolInfo { |
| 57 | return t.info |
no outgoing calls