Mastra agents use Pexafy through its MCP server, https://mcp.pexafy.com/mcp, with your API key in the Authorization header. The agent searches free-to-use photos (Unsplash, Pexels, Pixabay and more) and gets each one back with its licence and credit line.

Install

Mastra needs Node.js 22.13 or later.
npm install @mastra/core @mastra/mcp
export PEXAFY_API_KEY="pexafy_..."      # free key: pexafy.com/dashboard/api-keys/create
export ANTHROPIC_API_KEY="sk-ant-..."   # for this example; any Mastra model works

Use

import { Agent } from "@mastra/core/agent";
import { MCPClient } from "@mastra/mcp";

const mcp = new MCPClient({
  servers: {
    pexafy: {
      url: new URL("https://mcp.pexafy.com/mcp"),
      requestInit: { headers: { Authorization: `Bearer ${process.env.PEXAFY_API_KEY}` } },
    },
  },
});

const { pexafy } = await mcp.listToolsets();

const agent = new Agent({
  id: "photo-agent",
  name: "Photo agent",
  instructions: "Find free stock photos and give each photo's credit line.",
  model: "anthropic/claude-haiku-4-5",
  tools: { search_photos: pexafy.search_photos, search_photos_by_image: pexafy.search_photos_by_image },
});

const result = await agent.generate("Find a header photo for a post about remote work.");
console.log(result.text);
await mcp.disconnect();
The agent gets the two search tools. The other tools are for chat clients, where a person views a photo grid or links an account. On the free plan, show the credit line next to each photo you publish. See MCP server for the full tool list.