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

Function toPiTool

apps/sim/executor/handlers/pi/local-backend.ts:57–72  ·  view source on GitHub ↗
(sdk: PiSdk, spec: PiToolSpec)

Source from the content-addressed store, hash-verified

55}
56
57function toPiTool(sdk: PiSdk, spec: PiToolSpec): ToolDefinition {
58 return sdk.defineTool({
59 name: spec.name,
60 label: spec.name,
61 description: spec.description,
62 // double-cast-allowed: Pi accepts a plain JSON Schema at runtime (pi-ai validation.js coerceWithJsonSchema); the static type requires a TypeBox TSchema
63 parameters: spec.parameters as unknown as ToolDefinition['parameters'],
64 execute: async (_toolCallId, params) => {
65 const result = await spec.execute(params as Record<string, unknown>)
66 return {
67 content: [{ type: 'text', text: result.text }],
68 details: { isError: result.isError },
69 }
70 },
71 })
72}
73
74/**
75 * Builds a model definition for a provider Pi supports but whose bundled catalog

Callers 1

runLocalPiFunction · 0.85

Calls 1

executeMethod · 0.65

Tested by

no test coverage detected