@gdrl/mastra-programmatic-tool-calling
v0.1.0
Published
Programmatic tool calling for Mastra agents - run Python in Daytona sandbox with tool execution on Mastra server
Readme
@gdrl/mastra-programmatic-tool-calling
Programmatic tool calling for Mastra agents. The agent gets one tool (ptc_execute) and writes Python code that orchestrates multiple tool calls with logic (loops, conditionals, aggregations). Code runs in a Daytona sandbox; tool execution happens on the Mastra server. No HTTP endpoints required.
Install
npm install @gdrl/mastra-programmatic-tool-callingUsage
import { createPtcClient } from "@gdrl/mastra-programmatic-tool-calling";
import { weatherTool, timeTool } from "./tools";
const ptcClient = createPtcClient({
tools: { weather: weatherTool, time: timeTool },
daytonaApiKey: process.env.DAYTONA_API_KEY!,
daytonaApiUrl: process.env.DAYTONA_API_URL,
debug: true, // verbose logs of sandbox, tool calls, replay
});
// Add to any Mastra agent
const agent = new Agent({
tools: {
ptc_execute: ptcClient.agent_ptc_tool(),
},
instructions: ptcClient.agent_ptc_prompt(),
// ...model, etc.
});Test Agent
Run the Mastra server with the PTC test agent (uses get_quote, get_time, echo):
npm run dev:mastraRequires DAYTONA_API_KEY and optionally DAYTONA_API_URL. Set PTC_DEBUG=1 for verbose execution logs.
