Use Luni with the OpenAI Agents SDK

Attach Luni to an OpenAI Agents SDK agent as a Streamable HTTP MCP server. Works with OpenAI models, or Claude through LiteLLM.

Create a key

Luni's hosted MCP server is https://mcp.luni.gg, over Streamable HTTP. Code clients sign in with a workspace API key: create one with full access in your workspace and store it as LUNI_API_KEY. The examples send it in the Authorization: Bearer header; an X-API-Key header works too.

Install the packages below. The example also reads ANTHROPIC_API_KEY for the model; any model the framework supports can drive Luni's tools.

Install
pip install openai-agents
# For Claude as the model:
pip install "openai-agents[litellm]"

Connect your agent

The agent below loads Luni's tools from the MCP server and asks the model to read a page. Tested with openai-agents 0.24.0.

  • Both timeouts default to 5 seconds. Raise them as shown, because scraping and crawling take longer.
  • Without an OpenAI key the SDK logs a harmless tracing error; call set_tracing_disabled(True) to turn tracing off.
OpenAI Agents SDK
import asyncio
import os

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


async def main():
    async with MCPServerStreamableHttp(
        name="Luni",
        params={
            "url": "https://mcp.luni.gg",
            "headers": {"Authorization": f"Bearer {os.environ['LUNI_API_KEY']}"},
            "timeout": 30,
        },
        client_session_timeout_seconds=120,
    ) as luni:
        agent = Agent(
            name="Researcher",
            instructions="Use the Luni tools to read the web.",
            mcp_servers=[luni],
            # model="litellm/anthropic/claude-opus-5-5",  # to use Claude
        )
        result = await Runner.run(agent, "Scrape https://example.com and summarise the page in one sentence.")
        print(result.final_output)


asyncio.run(main())

What the agent can use

The agent sees sixteen tools. luni_scrape reads a URL, luni_search finds pages, luni_map lists a site's URLs and luni_crawl reads many pages of one site. luni_get_source_record returns a structured record from a supported source, and the monitor tools watch a page for changes. luni_get_operation reads stored results in chunks, so large pages never flood the context.

Tools that start paid work take a requestKey. The model fills it in from the tool's schema; repeating a call with the same key returns the saved result without another charge. Discovery, polling and balance checks are free.

Limits and safety

A Free workspace runs one operation at a time and 10 requests a minute, so tell the agent to call Luni tools one at a time. A tool that finds the workspace busy waits briefly, then answers with retryAfterSeconds.

Page content is untrusted data. Keep instructions in your own prompt, not in what Luni returns, and give the agent only the tools a task needs.

Other frameworks

The same server and key work in every MCP client.