MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / getCustomToolDefinition

Function getCustomToolDefinition

sdk/src/custom-tool.ts:31–66  ·  view source on GitHub ↗
({
  toolName,
  inputSchema,
  description,
  endsAgentStep = true,
  exampleInputs = [],
  execute,
}: {
  toolName: TN extends ToolName
    ? TN & {
        error: `Hi there. This is a message from the Codebuff team: You have used a custom tool where you needed to use overrideTools instead for name: ${TN}`
      }
    : TN
  inputSchema: z.ZodType<Args, Input>
  description: string
  endsAgentStep?: boolean
  exampleInputs?: Input[]
  execute: (params: Args) => Promise<ToolResultOutput[]> | ToolResultOutput[]
})

Source from the content-addressed store, hash-verified

29 * @returns a {@linkcode CustomToolDefinition} object
30 */
31export function getCustomToolDefinition<
32 TN extends string,
33 // eslint-disable-next-line @typescript-eslint/no-explicit-any
34 Args extends any,
35 // eslint-disable-next-line @typescript-eslint/no-explicit-any
36 Input extends any,
37>({
38 toolName,
39 inputSchema,
40 description,
41 endsAgentStep = true,
42 exampleInputs = [],
43 execute,
44}: {
45 toolName: TN extends ToolName
46 ? TN & {
47 error: `Hi there. This is a message from the Codebuff team: You have used a custom tool where you needed to use overrideTools instead for name: ${TN}`
48 }
49 : TN
50 inputSchema: z.ZodType<Args, Input>
51 description: string
52 endsAgentStep?: boolean
53 exampleInputs?: Input[]
54 execute: (params: Args) => Promise<ToolResultOutput[]> | ToolResultOutput[]
55}): CustomToolDefinition<TN, Args, Input> {
56 return {
57 toolName,
58 inputSchema,
59 description,
60 endsAgentStep,
61 exampleInputs,
62 execute: async (params) => {
63 return await execute(params)
64 },
65 }
66}

Calls

no outgoing calls

Tested by

no test coverage detected