APIs and frameworks
Model APIs and agent frameworks run without a person at a browser, so they connect with a Weir API
key, sent as Authorization: Bearer <key>. Create one under
API keys and keep it in WEIR_API_KEY.
Each example asks "What's my Weir usage?" A working connection calls get_usage, which is free.
Claude API
The Messages API connects to remote MCP servers itself, from Anthropic's cloud, so the URL has to
be public. Pass the key as authorization_token:
import os
import anthropic
client = anthropic.Anthropic()
response = client.beta.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
betas=["mcp-client-2025-11-20"],
mcp_servers=[
{
"type": "url",
"url": "https://api.weirapp.io/mcp",
"name": "weir",
"authorization_token": os.environ["WEIR_API_KEY"],
}
],
tools=[{"type": "mcp_toolset", "mcp_server_name": "weir"}],
messages=[{"role": "user", "content": "What's my Weir usage?"}],
)Both halves are required: the server in mcp_servers, and an mcp_toolset that names it.
OpenAI Responses API
OpenAI calls Weir from its own servers. Send the key in headers:
import os
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model=os.environ["OPENAI_MODEL"], # any model that supports remote MCP
tools=[
{
"type": "mcp",
"server_label": "weir",
"server_url": "https://api.weirapp.io/mcp",
"headers": {"Authorization": f"Bearer {os.environ['WEIR_API_KEY']}"},
"require_approval": {"never": {"read_only": True}},
}
],
input="What's my Weir usage?",
)
print(response.output_text)require_approval decides which calls stop and wait for your approval. The setting above lets tools
marked read-only run straight away and asks before anything else. Leave it out and every call
waits for approval.
The MCP tool is part of the Responses API. Chat Completions does not have it.
OpenAI Agents SDK
Your process connects to Weir:
import asyncio
import os
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp
async def main() -> None:
async with MCPServerStreamableHttp(
name="weir",
params={
"url": "https://api.weirapp.io/mcp",
"headers": {"Authorization": f"Bearer {os.environ['WEIR_API_KEY']}"},
"timeout": 30,
},
client_session_timeout_seconds=30,
cache_tools_list=True,
) as weir:
agent = Agent(name="analyst", mcp_servers=[weir])
result = await Runner.run(agent, "What's my Weir usage?")
print(result.final_output)
asyncio.run(main())Raise the timeouts as shown. The SDK's default is five seconds, and a search or a comment tree can
take longer. The JavaScript SDK's MCPServerStreamableHttp takes the same header under
requestInit.headers.
LangChain
With langchain-mcp-adapters:
import asyncio
import os
from langchain_mcp_adapters.client import MultiServerMCPClient
async def main() -> None:
client = MultiServerMCPClient(
{
"weir": {
"transport": "streamable_http",
"url": "https://api.weirapp.io/mcp",
"headers": {"Authorization": f"Bearer {os.environ['WEIR_API_KEY']}"},
}
}
)
tools = await client.get_tools()
print([tool.name for tool in tools])
asyncio.run(main())LangChain prefixes the tool names with the server name. In JavaScript, @langchain/mcp-adapters
takes the same url and headers.
Vercel AI SDK
import { createMCPClient } from "@ai-sdk/mcp";
const weir = await createMCPClient({
transport: {
type: "http",
url: "https://api.weirapp.io/mcp",
headers: { Authorization: `Bearer ${process.env.WEIR_API_KEY}` },
},
});
const tools = await weir.tools();Pass tools to generateText or streamText, and call weir.close() when you are done.
createMCPClient comes from @ai-sdk/mcp, not from ai.
n8n
Add an MCP Client Tool node to your AI agent and set:
| Setting | Value |
|---|---|
| Endpoint | https://api.weirapp.io/mcp |
| Server Transport | HTTP Streamable |
| Authentication | Bearer Auth, with a credential holding your key |
| Tools to Include | All |
Older workflows default the transport to SSE, which Weir does not serve. Switch it to HTTP Streamable. n8n's MCP OAuth2 credential also works, if you would rather sign in than store a key.