# Use Webcite with the OpenAI Agents SDK through MCP

Canonical URL: https://webcite.co/integrations/openai-agents-sdk | Last updated: 2026-11-25

To use Webcite from the OpenAI Agents SDK, open webcite-mcp-server with MCPServerStdio, or the hosted server at https://api.webcite.co/mcp with MCPServerStreamableHttp, and pass it to an Agent in mcp_servers. The agent gets all 34 Webcite tools. This guide was run with openai-agents 0.26.0 and webcite-mcp-server 1.9.67 on Node.js 22.

## Install

```bash
pip install openai-agents
export WEBCITE_API_KEY="YOUR_API_KEY"
```

The npm server needs an API key from the [API keys page](https://webcite.co/api-keys) in `WEBCITE_API_KEY`. Keep it on your server.

## Local server: list the tools and verify a claim

```python
import asyncio
import os

from agents import Agent
from agents.mcp import MCPServerStdio


async def main():
    async with MCPServerStdio(
        params={
            "command": "npx",
            "args": ["-y", "webcite-mcp-server"],
            "env": {"WEBCITE_API_KEY": os.environ["WEBCITE_API_KEY"], "PATH": os.environ["PATH"]},
        },
        client_session_timeout_seconds=60,
    ) as server:
        tools = await server.list_tools()
        print(len(tools), "tools")

        result = await server.call_tool(
            "verify_claim",
            {"claim": "The Great Wall of China is visible from the Moon with the naked eye."},
        )
        print(result.content[0].text)

        agent = Agent(
            name="Fact checker",
            instructions="Verify claims with Webcite and cite the sources it returns.",
            mcp_servers=[server],
        )


asyncio.run(main())
```

This prints 34 tools, then the verification, which costs 4 credits ([saved response for this claim](https://webcite.co/samples/claim-great-wall.json)). The session timeout is raised to 60 seconds because the default of 5 can be shorter than the first `npx` download.

## Hosted server, no Node.js

```python
import asyncio
import os

from agents.mcp import MCPServerStreamableHttp


async def main():
    async with MCPServerStreamableHttp(
        params={
            "url": "https://api.webcite.co/mcp",
            "headers": {"Authorization": f"Bearer {os.environ['WEBCITE_API_KEY']}"},
        },
    ) as server:
        tools = await server.list_tools()
        print(len(tools), "tools")
        result = await server.call_tool(
            "verify_claim",
            {"claim": "The Great Wall of China is visible from the Moon with the naked eye."},
        )
        print(result.content[0].text)


asyncio.run(main())
```

The tool list loads before the key is checked, so a working list does not prove the key is valid; the first paid call does.

## Run the agent

Pass the server in `mcp_servers` as above, then run the agent with `Runner.run` inside the same `async with` block; the model decides when to call the tools. That step needs your OpenAI API key. Tell the agent to call `webcite_guide` first.

## If a call fails

- A missing or wrong key comes back as a tool result that starts with `Error [unauthorized]` and says how to reconnect; the call does not raise.
- [Errors and rate limits](https://webcite.co/api-docs/errors) covers retries without repeating paid work.

[Get an API key](https://webcite.co/signup)
