OpenAI Agents SDK 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

pip install openai-agents
npm install @openai/agents zod
export PEXAFY_API_KEY="pexafy_..."   # free key: pexafy.com/dashboard/api-keys/create
export OPENAI_API_KEY="sk-..."

Use

import asyncio
import os

from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp, create_static_tool_filter


async def main():
    async with MCPServerStreamableHttp(
        name="pexafy",
        params={
            "url": "https://mcp.pexafy.com/mcp",
            "headers": {"Authorization": f"Bearer {os.environ['PEXAFY_API_KEY']}"},
        },
        tool_filter=create_static_tool_filter(
            allowed_tool_names=["search_photos", "search_photos_by_image"]
        ),
    ) as pexafy:
        agent = Agent(
            name="Illustrator",
            instructions="Find free stock photos and give each photo's credit line.",
            mcp_servers=[pexafy],
        )
        result = await Runner.run(agent, "Find a header photo for a post about remote work.")
        print(result.final_output)


asyncio.run(main())
import { Agent, MCPServerStreamableHttp, createMCPToolStaticFilter, run } from "@openai/agents";

const pexafy = new MCPServerStreamableHttp({
  name: "pexafy",
  url: "https://mcp.pexafy.com/mcp",
  requestInit: { headers: { Authorization: `Bearer ${process.env.PEXAFY_API_KEY}` } },
  toolFilter: createMCPToolStaticFilter({ allowed: ["search_photos", "search_photos_by_image"] }),
});

await pexafy.connect();
try {
  const agent = new Agent({
    name: "Illustrator",
    instructions: "Find free stock photos and give each photo's credit line.",
    mcpServers: [pexafy],
  });
  const result = await run(agent, "Find a header photo for a post about remote work.");
  console.log(result.finalOutput);
} finally {
  await pexafy.close();
}
The tool filter keeps the two search tools. The other tools are for chat clients, where a person views a photo grid or links an account.

Hosted MCP

With a hosted MCP tool, OpenAI’s servers call Pexafy for you and your code opens no MCP connection:
import os

from agents import Agent, HostedMCPTool, Runner

agent = Agent(
    name="Illustrator",
    instructions="Find free stock photos and give each photo's credit line.",
    tools=[
        HostedMCPTool(
            tool_config={
                "type": "mcp",
                "server_label": "pexafy",
                "server_url": "https://mcp.pexafy.com/mcp",
                "headers": {"Authorization": f"Bearer {os.environ['PEXAFY_API_KEY']}"},
                "allowed_tools": ["search_photos", "search_photos_by_image"],
                "require_approval": "never",
            }
        )
    ],
)

result = Runner.run_sync(agent, "Find a header photo for a post about remote work.")
print(result.final_output)
import { Agent, hostedMcpTool, run } from "@openai/agents";

const agent = new Agent({
  name: "Illustrator",
  instructions: "Find free stock photos and give each photo's credit line.",
  tools: [
    hostedMcpTool({
      serverLabel: "pexafy",
      serverUrl: "https://mcp.pexafy.com/mcp",
      headers: { Authorization: `Bearer ${process.env.PEXAFY_API_KEY}` },
      allowedTools: ["search_photos", "search_photos_by_image"],
      requireApproval: "never",
    }),
  ],
});

const result = await run(agent, "Find a header photo for a post about remote work.");
console.log(result.finalOutput);
On the free plan, show the credit line next to each photo you publish. See MCP server for the full tool list.