How to Use the BallDontLie MCP in Mastra AI
Build resilient, automated NBA data workflows using Mastra AI and the BallDontLie MCP Server.
Works with every AI agent you already use
…and any MCP-compatible client
Connect BallDontLie MCP to Mastra AI
Create your Vinkius account to connect BallDontLie to Mastra AI and route execution through our secure gateway. The platform manages server hosting, runtime updates, and security layers. Configuration requires no manual server provisioning.
Build Resilient Player Workflows with Mastra AI
Using the `list_players` tool searches the NBA database, and `get_season_averages` pulls their seasonal performance metrics. Mastra AI runs these tools inside automated workflows, letting you chain search queries and stat lookups together. If the upstream sports data source experiences a temporary blip, Mastra's built-in retry mechanism handles exponential backoff automatically. Your Mastra agent will keep trying until it secures the NBA player data, preventing workflow crashes.
Branch Workflows Based on Live Game Results
Querying `list_games` retrieves scheduled matchups, while `get_game_details` and `list_player_stats` expose specific game outcomes and box scores. Mastra AI uses these tools to execute conditional branches based on court events like a blowout game or a high-scoring night. You can write Mastra logic that triggers a secondary analysis if an NBA player scores over thirty points, or alerts an editor if a game goes into overtime. The Mastra workflow engine handles the branching logic while this MCP Server provides the raw game numbers.
Sync NBA Team Data via MCP Server Workflows
Executing `list_teams` fetches active franchises, and `get_team_details` retrieves granular details about specific organizations. Mastra AI agents use these tools to keep local databases synchronized with active NBA rosters. Because Mastra deploys with a single command to any cloud provider, you can schedule these NBA sync tasks to run on a cron job. The Mastra framework handles the scheduling, while Vinkius manages the secure connection to the BallDontLie endpoint.
Set up BallDontLie MCP in Mastra AI
Prerequisites
- Node.js 18+ and a TypeScript project
-
@mastra/mcp+@mastra/corepackages - Active Vinkius subscription with a valid endpoint token
- 1
Install dependencies
Run
npm install @mastra/mcp @mastra/coreplus your preferred model provider (e.g.@ai-sdk/openai). - 2
Configure the MCPClient
Create an
MCPClientwith your Vinkius endpoint as aURLobject. Replace[YOUR_TOKEN_HERE]with your token from cloud.vinkius.com. - 3
Discover and inject tools
Call
mcpClient.listTools()and spread the result into your agent'stoolsobject. All BallDontLie tools become native Mastra tools. - 4
Run with any model
Swap
openai("gpt-4o")for any AI SDK-compatible provider. Callagent.generate()and the agent routes tool calls through MCP automatically.
import { MCPClient } from "@mastra/mcp";
import { Agent } from "@mastra/core/agent";
import { openai } from "@ai-sdk/openai";
const mcpClient = new MCPClient({
id: "balldontlie-mcp-client",
servers: {
"balldontlie-mcp": {
url: new URL(
"https://edge.vinkius.com/[YOUR_TOKEN_HERE]/mcp"
),
},
},
});
const agent = new Agent({
name: "BallDontLie Agent",
model: openai("gpt-4o"),
instructions: "You have access to BallDontLie tools.",
tools: {
...(await mcpClient.listTools()),
},
});
const result = await agent.generate(
"List recent BallDontLie transactions"
);
console.log(result.text); Independent Platform Disclaimer: Vinkius is an independent platform and is not affiliated with, endorsed by, sponsored by, verified by, or otherwise authorized by BallDontLie. All third-party trademarks, logos, and brand names are the property of their respective owners. Their use on this website is strictly for informational purposes to identify service compatibility and interoperability.
Why Choose Vinkius
Vinkius connects your tools to AI with real-time monitoring and automatic cost savings — all from one dashboard.
Real-time monitoring
Live
visibility into every interaction
Connect your favorite tools to your AI and see exactly what's happening — every request, every response, in real time.
Built-in savings
60%
lower AI costs
Vinkius compresses data between your apps and your AI automatically. Lower bills every month — no configuration required.
Single dashboard
One
place for every integration
Every tool your AI connects to, managed from a single screen. One account, complete control.
Common questions about BallDontLie MCP in Mastra AI
Use it with your favorite AI tools
Connect this server to Cursor, Claude, VS Code, and more.
Start using the BallDontLie MCP today
We host it, we monitor it, we maintain it. You just paste one token.