MCPcopy Index your code
hub / github.com/simstudioai/sim / createToolConfig

Function createToolConfig

apps/sim/tools/utils.ts:297–335  ·  view source on GitHub ↗
(
  customTool: CustomToolDefinition,
  customToolId: string
)

Source from the content-addressed store, hash-verified

295
296// Helper function to create a tool config from a custom tool
297export function createToolConfig(
298 customTool: CustomToolDefinition,
299 customToolId: string
300): ToolConfig {
301 // Create a parameter schema from the custom tool schema
302 const params = createParamSchema(customTool)
303
304 // Create a tool config for the custom tool
305 return {
306 id: customToolId,
307 name: customTool.title,
308 description: customTool.schema.function?.description || '',
309 version: '1.0.0',
310 params,
311
312 // Request configuration - for custom tools we'll use the execute endpoint
313 request: {
314 url: '/api/function/execute',
315 method: 'POST',
316 headers: () => ({ 'Content-Type': 'application/json' }),
317 body: createCustomToolRequestBody(customTool, true),
318 },
319
320 // Standard response handling for custom tools
321 transformResponse: async (response: Response) => {
322 const data = await response.json()
323
324 if (!data.success) {
325 throw new Error(data.error || 'Custom tool execution failed')
326 }
327
328 return {
329 success: true,
330 output: data.output.result || data.output,
331 error: undefined,
332 }
333 },
334 }
335}

Callers 1

fetchCustomToolFromDBFunction · 0.90

Calls 2

createParamSchemaFunction · 0.85

Tested by

no test coverage detected