MCPcopy
hub / github.com/TanStack/ai / toolDefinition

Function toolDefinition

packages/ai/src/activities/chat/tools/tool-definition.ts:191–223  ·  view source on GitHub ↗
(
  config: ToolDefinitionConfig<TInput, TOutput, TName>,
)

Source from the content-addressed store, hash-verified

189 * ```
190 */
191export function toolDefinition<
192 TInput extends SchemaInput = SchemaInput,
193 TOutput extends SchemaInput = SchemaInput,
194 TName extends string = string,
195>(
196 config: ToolDefinitionConfig<TInput, TOutput, TName>,
197): ToolDefinition<TInput, TOutput, TName> {
198 const definition: ToolDefinition<TInput, TOutput, TName> = {
199 __toolSide: 'definition',
200 ...config,
201 server<TContext = unknown>(
202 execute: ToolExecuteFunction<TInput, TOutput, TContext>,
203 ): ServerTool<TInput, TOutput, TName, TContext> {
204 return {
205 __toolSide: 'server',
206 ...config,
207 execute,
208 }
209 },
210
211 client<TContext = unknown>(
212 execute?: ToolExecuteFunction<TInput, TOutput, TContext>,
213 ): ClientTool<TInput, TOutput, TName, TContext> {
214 return {
215 __toolSide: 'client',
216 ...config,
217 ...(execute !== undefined && { execute }),
218 }
219 },
220 }
221
222 return definition
223}

Callers 15

database-tools.tsFile · 0.90
createCodeModeToolFunction · 0.90
createDiscoveryToolFunction · 0.90
createMockToolFunction · 0.90
createMockServerToolFunction · 0.90
createMockToolFunction · 0.90
createMockToolFunction · 0.90

Calls

no outgoing calls

Tested by 4

createMockToolFunction · 0.72
createMockServerToolFunction · 0.72
createMockToolFunction · 0.72
createMockToolFunction · 0.72