MCP

Connect OpenAI Agents SDK

Give an agent built with the OpenAI Agents SDK (Python) the CoinGraph tools.

  1. Install and get a key

    Code can't open a sign-in window, so it sends an account key instead. Create one on your keys (how) and keep it in an environment variable.

    Terminal
    pip install openai-agents
    export COINGRAPH_KEY=cg_live_…
  2. Connect and run

    Python
    import asyncio, os
    from agents import Agent, Runner
    from agents.mcp import MCPServerStreamableHttp
    
    async def main():
        async with MCPServerStreamableHttp(name="CoinGraph", params={"url": "https://coingraph.ai/mcp", "headers": {"Authorization": f"Bearer {os.environ['COINGRAPH_KEY']}"}}) as coingraph:
            agent = Agent(
                name="Trader",
                instructions="Before any trade, check it with CoinGraph and quote the proof id.",
                mcp_servers=[coingraph],
            )
            result = await Runner.run(agent, "Check Chainlink before I buy $5K. Use CoinGraph and show me the proof.")
            print(result.final_output)
    
    asyncio.run(main())

Check it works #

The output quotes CoinGraph's verdict and a proof id; the run's tool calls show check_token or run_trade_gatekeeper.

i

Note

Sign-in and what each call costs: Keys & pricing. Every tool with its inputs: Tools.