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

Function createTool

packages/server/src/services/tools/index.ts:11–32  ·  view source on GitHub ↗
(requestBody: any, orgId: string)

Source from the content-addressed store, hash-verified

9import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
10
11const createTool = async (requestBody: any, orgId: string): Promise<any> => {
12 try {
13 const appServer = getRunningExpressApp()
14 const newTool = new Tool()
15 Object.assign(newTool, requestBody)
16 const tool = await appServer.AppDataSource.getRepository(Tool).create(newTool)
17 const dbResponse = await appServer.AppDataSource.getRepository(Tool).save(tool)
18 await appServer.telemetry.sendTelemetry(
19 'tool_created',
20 {
21 version: await getAppVersion(),
22 toolId: dbResponse.id,
23 toolName: dbResponse.name
24 },
25 orgId
26 )
27 appServer.metricsProvider?.incrementCounter(FLOWISE_METRIC_COUNTERS.TOOL_CREATED, { status: FLOWISE_COUNTER_STATUS.SUCCESS })
28 return dbResponse
29 } catch (error) {
30 throw new InternalFlowiseError(StatusCodes.INTERNAL_SERVER_ERROR, `Error: toolsService.createTool - ${getErrorMessage(error)}`)
31 }
32}
33
34const deleteTool = async (toolId: string, workspaceId: string): Promise<any> => {
35 try {

Callers

nothing calls this directly

Calls 6

getRunningExpressAppFunction · 0.90
getAppVersionFunction · 0.90
getErrorMessageFunction · 0.90
sendTelemetryMethod · 0.80
incrementCounterMethod · 0.65
createMethod · 0.45

Tested by

no test coverage detected