MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / MCPTool

Function MCPTool

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

Source from the content-addressed store, hash-verified

210}
211
212export async function MCPTool({
213 toolkit,
214 name,
215 description,
216 argsSchema
217}: {
218 toolkit: MCPToolkit
219 name: string
220 description: string
221 argsSchema: any
222}): Promise<Tool> {
223 return tool(
224 async (input): Promise<string> => {
225 // Create a new client for this request
226 const toolCallHeaders = await toolkit.getToolCallHeaders?.()
227 const client = await toolkit.createClient(toolCallHeaders)
228
229 try {
230 const req: CallToolRequest = { method: 'tools/call', params: { name: name, arguments: input as any } }
231 const res = await client.request(req, CallToolResultSchema)
232 const content = res.content
233 const contentString = JSON.stringify(content)
234 return contentString
235 } finally {
236 // Always close the client after the request completes
237 await client.close()
238 }
239 },
240 {
241 name: name,
242 description: description,
243 schema: argsSchema
244 }
245 )
246}
247
248export const validateArgsForLocalFileAccess = (args: string[]): void => {
249 const allowedScriptPaths = (process.env.CUSTOM_MCP_ALLOWED_ABSOLUTE_SCRIPT_PATHS ?? '')

Callers 1

get_toolsMethod · 0.85

Calls 3

createClientMethod · 0.80
stringifyMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected