Agent SDKs and frameworks

Connect Thirdfy MCP from the Claude Agent SDK, OpenAI Agents SDK, Vercel AI SDK and LangChain with an agent key header.

Build your own agent on Thirdfy. Each SDK below connects to https://mcp.thirdfy.com/mcp over streamable HTTP and sends your agent key in the Authorization header.

FrameworkLanguage
Claude Agent SDKTypeScript, Python
OpenAI Agents SDKPython
Vercel AI SDKTypeScript
LangChainPython

Before you start

Open thirdfy.com/connect, go to Agent key, pick the agent and click Create a key. The key (agent-...) is shown once, so store it right away. Then export it:

export AGENT_API_KEY="agent-..."

Every snippet reads the key from AGENT_API_KEY and sends it as a connection header. Never put the key in a prompt or a tool argument. If the model passes a different key in arguments, Thirdfy answers AGENT_IDENTITY_MISMATCH and uses the header key. Without a key, /mcp answers 401.

Keep writes under control

Your code decides which tools the model can call. In every framework:

  • Load only the tools the task needs. A research agent needs getProviderActions, getVenueReadiness and agentRun. Add previewOrder and walletExecute only for an agent that trades.
  • Ask a person before a write. Each section shows how to pause on walletExecute until someone approves it.
  • Set limits in Thirdfy. The agent's action allowlist and daily limit apply to every call, whatever the model asks for. See Delegation & protection.

Thirdfy refuses any write that fails its checks (allowlist, daily limit, venue readiness, credits).

Claude Agent SDK

Pass Thirdfy in mcpServers with type: "http". Tool names take the form mcp__thirdfy__<tool>. Tools in allowedTools run without asking. Any other tool goes to your canUseTool callback, so leave walletExecute out of allowedTools and approve it there. See Anthropic's Agent SDK MCP docs.

TypeScript
Python
import { query } from "@anthropic-ai/claude-agent-sdk";

for await (const message of query({
  prompt: "Using Thirdfy, run get_openmarket_btc_funding and summarize it.",
  options: {
    model: "claude-opus-5-5",
    mcpServers: {
      thirdfy: {
        type: "http",
        url: "https://mcp.thirdfy.com/mcp",
        headers: {
          Authorization: `Bearer ${process.env.AGENT_API_KEY}`,
        },
      },
    },
    allowedTools: [
      "mcp__thirdfy__getProviderActions",
      "mcp__thirdfy__getVenueReadiness",
      "mcp__thirdfy__agentRun",
    ],
  },
})) {
  if (message.type === "result" && message.subtype === "success") {
    console.log(message.result);
  }
}

Install with npm install @anthropic-ai/claude-agent-sdk or pip install claude-agent-sdk. The SDK doesn't run a browser sign-in, so use the agent key header. If the server shows needs-auth in the system init message, the header is missing.

OpenAI Agents SDK

Open Thirdfy with MCPServerStreamableHttp and give it to the agent in mcp_servers. tool_filter limits the tools the model sees. require_approval pauses the run on the tools you name. See OpenAI's Agents SDK MCP docs.

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="thirdfy",
        params={
            "url": "https://mcp.thirdfy.com/mcp",
            "headers": {"Authorization": f"Bearer {os.environ['AGENT_API_KEY']}"},
        },
        cache_tools_list=True,
        tool_filter=create_static_tool_filter(
            allowed_tool_names=["getProviderActions", "getVenueReadiness", "agentRun"]
        ),
        require_approval={"always": {"tool_names": ["walletExecute"]}},
    ) as thirdfy:
        agent = Agent(
            name="Thirdfy agent",
            instructions="Use the Thirdfy tools to read markets. Never place an order.",
            mcp_servers=[thirdfy],
        )
        result = await Runner.run(
            agent, "Using Thirdfy, run get_openmarket_btc_funding and summarize it."
        )
        print(result.final_output)


asyncio.run(main())

Install with pip install openai-agents. When you add walletExecute to allowed_tool_names, a call to it stops the run and shows up in result.interruptions. Approve it with state = result.to_state(), state.approve(...), then Runner.run(agent, state). See Human-in-the-loop.

Vercel AI SDK

Create a client with createMCPClient from @ai-sdk/mcp and an http transport. mcpClient.tools() returns every Thirdfy tool, so pick the ones you need before you pass them to the model. See the AI SDK's MCP tools docs.

import { createMCPClient } from "@ai-sdk/mcp";
import { anthropic } from "@ai-sdk/anthropic";
import { generateText, isStepCount } from "ai";

const mcpClient = await createMCPClient({
  transport: {
    type: "http",
    url: "https://mcp.thirdfy.com/mcp",
    headers: { Authorization: `Bearer ${process.env.AGENT_API_KEY}` },
  },
});

try {
  const all = await mcpClient.tools();
  const { getProviderActions, getVenueReadiness, agentRun } = all;

  const { text } = await generateText({
    model: anthropic("claude-opus-5-5"),
    tools: { getProviderActions, getVenueReadiness, agentRun },
    stopWhen: isStepCount(5),
    prompt: "Using Thirdfy, run get_openmarket_btc_funding and summarize it.",
  });
  console.log(text);
} finally {
  await mcpClient.close();
}

Install with npm install ai @ai-sdk/mcp @ai-sdk/anthropic, or use any other AI SDK provider. For an agent that trades, add walletExecute to tools and set toolApproval: { walletExecute: "user-approval" }. The call then comes back as an approval request instead of running. See Tool approvals.

LangChain

LangChain 1.4 and later ships MCP support in langchain.mcp, which replaces the langchain-mcp-adapters package. Pass a fastmcp client with your key as auth, and MCPAdapter turns Thirdfy's tools into LangChain tools for create_agent. See LangChain's MCP docs.

import asyncio
import os

from fastmcp.client import Client
from langchain.agents import create_agent
from langchain.mcp import MCPAdapter

READ_TOOLS = {"getProviderActions", "getVenueReadiness", "agentRun"}


async def main():
    client = Client("https://mcp.thirdfy.com/mcp", auth=os.environ["AGENT_API_KEY"])
    async with MCPAdapter(client) as adapter:
        tools = [t for t in await adapter.list_tools() if t.name in READ_TOOLS]
        agent = create_agent("anthropic:claude-opus-5-5", tools)
        result = await agent.ainvoke(
            {
                "messages": [
                    {
                        "role": "user",
                        "content": "Using Thirdfy, run get_openmarket_btc_funding and summarize it.",
                    }
                ]
            }
        )
        print(result["messages"][-1].content)


asyncio.run(main())

Install with pip install "langchain[mcp]" langchain-anthropic. A string auth is sent as Authorization: Bearer <key>. create_agent builds a LangGraph agent. For writes, pass middleware=[HumanInTheLoopMiddleware(interrupt_on={"walletExecute": True})] and a checkpointer. The run pauses on walletExecute until you resume it with an approve decision. See Human-in-the-loop. Still on langchain-mcp-adapters? Follow LangChain's migration guide.

Try it

Use these as the prompt in any of the snippets above:

Using Thirdfy, list the OpenMarket actions, run get_openmarket_btc_funding
and summarize what the funding rate says about positioning.
Using Thirdfy, check whether my Hyperliquid venue is ready to trade and list
anything that blocks it. Don't place any order.

For the venue check, give the agent getVenueReadiness. It takes { "venue": "hyperliquid", "agentKey": "0x…" }.

Troubleshooting

IssueFix
401 Authentication requiredAGENT_API_KEY is not set, or the header is missing. Check Authorization: Bearer agent-...
Tool not foundMatch names exactly to GET https://mcp.thirdfy.com/tools, and include them in your tool list or filter
Model calls a tool you didn't expectNarrow the tool list, and the key's action allowlist in Thirdfy
Run stops on walletExecuteThat is the approval step. Approve or reject it, then resume
AGENT_IDENTITY_MISMATCHThe model passed a different key in arguments. The header key is used