MCPcopy
hub / github.com/FlowiseAI/Flowise / MCPTool

Function MCPTool

packages/components/nodes/tools/MCP/core.ts:145–179  ·  view source on GitHub ↗
({
    toolkit,
    name,
    description,
    argsSchema
}: {
    toolkit: MCPToolkit
    name: string
    description: string
    argsSchema: any
})

Source from the content-addressed store, hash-verified

143}
144
145export async function MCPTool({
146 toolkit,
147 name,
148 description,
149 argsSchema
150}: {
151 toolkit: MCPToolkit
152 name: string
153 description: string
154 argsSchema: any
155}): Promise<Tool> {
156 return tool(
157 async (input): Promise<string> => {
158 // Create a new client for this request
159 const toolCallHeaders = await toolkit.getToolCallHeaders?.()
160 const client = await toolkit.createClient(toolCallHeaders)
161
162 try {
163 const req: CallToolRequest = { method: 'tools/call', params: { name: name, arguments: input as any } }
164 const res = await client.request(req, CallToolResultSchema)
165 const content = res.content
166 const contentString = JSON.stringify(content)
167 return contentString
168 } finally {
169 // Always close the client after the request completes
170 await client.close()
171 }
172 },
173 {
174 name: name,
175 description: description,
176 schema: argsSchema
177 }
178 )
179}
180
181export const validateArgsForLocalFileAccess = (args: string[]): void => {
182 const dangerousPatterns = [

Callers 1

get_toolsMethod · 0.85

Calls 3

createClientMethod · 0.80
stringifyMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected