Skip to content

feat: add Mastra framework extension#1037

Open
vijaygopalbalasa wants to merge 1 commit intocoinbase:mainfrom
vijaygopalbalasa:feat/mastra-framework-extension
Open

feat: add Mastra framework extension#1037
vijaygopalbalasa wants to merge 1 commit intocoinbase:mainfrom
vijaygopalbalasa:feat/mastra-framework-extension

Conversation

@vijaygopalbalasa
Copy link

Summary

Adds @coinbase/agentkit-mastra — a new framework extension that enables AgentKit usage with Mastra, the TypeScript AI agent framework (YC W25, from the team behind Gatsby).

  • Core function: getMastraTools(agentKit) converts AgentKit actions into Mastra-compatible tools via createTool from @mastra/core/tools
  • Pattern: Follows the exact same structure as existing @coinbase/agentkit-langchain and @coinbase/agentkit-vercel-ai-sdk extensions
  • API mapping: action.name → id, action.description → description, action.schema → inputSchema, action.invoke → execute
  • Targets: @mastra/core >= 1.0.0 (uses the 1.x createTool execute signature where inputData is the first parameter)
  • Zod 4 compatible across all packages

Files added

typescript/framework-extensions/mastra/
├── src/
│   ├── index.ts                  # Re-exports getMastraTools
│   ├── getMastraTools.ts         # Core adapter (15 lines of logic)
│   └── getMastraTools.test.ts    # 3 test cases (basic, multi-action, empty)
├── package.json                  # @coinbase/agentkit-mastra v0.1.0
├── README.md                     # Installation + usage with Mastra Agent
├── tsconfig.json
├── jest.config.cjs
├── .eslintrc.json
├── .prettierrc
├── .prettierignore
└── setup-jest.js

Verification

  • ✅ Build passes (tsc clean)
  • ✅ All 3 tests pass
  • ✅ Lint clean
  • ✅ Format clean
  • createTool API verified against @mastra/core@1.15.0
  • ✅ Zod 4 compatibility confirmed
  • pnpm-workspace.yaml glob framework-extensions/* auto-includes the new package

Usage

import { getMastraTools } from "@coinbase/agentkit-mastra";
import { AgentKit } from "@coinbase/agentkit";
import { Agent } from "@mastra/core/agent";

const agentKit = await AgentKit.from({ /* wallet config */ });
const tools = getMastraTools(agentKit);

const agent = new Agent({
  name: "Onchain Agent",
  instructions: "You are an onchain AI assistant with access to a wallet.",
  model: openai("gpt-4o-mini"),
  tools,
});

const response = await agent.generate("What's my wallet balance?");

Resolves WISHLIST.md item: "Mastra" under AI Framework Support.

Test plan

  • pnpm --filter @coinbase/agentkit-mastra build — compiles clean
  • pnpm --filter @coinbase/agentkit-mastra test — 3/3 pass
  • pnpm --filter @coinbase/agentkit-mastra lint — no errors
  • pnpm --filter @coinbase/agentkit-mastra format:check — clean
  • CI pipeline validation

@cb-heimdall
Copy link

cb-heimdall commented Mar 23, 2026

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@github-actions github-actions bot added documentation Improvements or additions to documentation framework extension New framework extension typescript labels Mar 23, 2026
Adds a new framework extension that converts AgentKit actions into
Mastra-compatible tools via getMastraTools(), enabling AgentKit usage
with the Mastra AI agent framework.

- Follows the same pattern as existing LangChain and Vercel AI SDK extensions
- Maps AgentKit Action (name, description, schema, invoke) to Mastra createTool
- Includes unit tests (3 test cases), README with usage examples
- Targets @mastra/core >= 1.0.0 (1.x createTool execute signature)
- Zod 4 compatible across all packages

Resolves WISHLIST.md item: "Mastra" under AI Framework Support.
@vijaygopalbalasa vijaygopalbalasa force-pushed the feat/mastra-framework-extension branch from d92e244 to ca2120b Compare March 23, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation framework extension New framework extension typescript

Development

Successfully merging this pull request may close these issues.

2 participants