Skip to main content
Mastra loads SAN through the MCPClient from @mastra/mcp. It exposes SAN’s tools to any Mastra Agent.

Prerequisites

  • Node.js 20+
  • A SAN API key
    Create one in the API Quickstart if you don’t have one yet.

Quick Start

1

Install the packages

npm install @mastra/core @mastra/mcp
2

Point an MCPClient at SAN

A url created with new URL() uses streamable HTTP. Pass your key under requestInit.headers.
import { MCPClient } from '@mastra/mcp'

const mcp = new MCPClient({
  servers: {
    san: {
      url: new URL('https://gateway.sanfoundation.com/mcp'),
      requestInit: {
        headers: {
          'x-api-key': process.env.SAN_API_KEY!, // "sk_..."
        },
      },
    },
  },
})
3

Give the tools to an agent

listTools() fetches SAN’s tools once so you can bind them to an agent.
import { Agent } from '@mastra/core/agent'

export const sanAgent = new Agent({
  name: 'SAN Agent',
  instructions: 'You have access to the SAN MCP server tools.',
  model: 'openai/gpt-4.1', // any model your Mastra setup supports
  tools: await mcp.listTools(),
})
On Mastra v0 (pre-1.0), the method is getTools() instead of listTools().