tdm-mastra
v0.1.0
Published
Payable Mastra tool wrappers powered by TDM authorization
Downloads
120
Maintainers
Readme
tdm-mastra
Make Mastra tools payable with TDM.
This package keeps the Mastra developer experience intact:
- build a normal Mastra tool with
createTool(...) - add the TDM payment fields
- authorize through
POST /authorize - run the original tool logic only after TDM allows it
Install
npm install tdm-mastra tdm-sdk @mastra/core zodExample
import { z } from "zod";
import { createTdmMastraTool } from "tdm-mastra";
export const premiumResearchTool = createTdmMastraTool({
baseUrl: process.env.TDM_GATEWAY_URL!,
apiKey: process.env.TDM_API_KEY,
id: "premium-research",
description: "Run a paid research action after TDM authorization.",
inputSchema: z.object({
topic: z.string().min(1),
}),
outputSchema: z.object({
summary: z.string(),
}),
execute: async ({ topic }) => {
return {
summary: `Research summary for ${topic}`,
};
},
});Input shape
Every tool created by createTdmMastraTool(...) includes these TDM fields:
tokenOrUuidoperationresourceId?priceUsd?
Your own schema is merged into that base shape.
Notes
- This package uses the public TDM contract behind
POST /authorize. - It avoids private gateway or treasury logic.
- For lower-level control, use
tdm-sdk/make-payabledirectly.
License
MIT
