OpenAI Agents SDK
OAuth connections share one ScriptHaul allowance pool across your account’s connected apps. Review the client name and redirect destination host before approving. Reconnect when prompted, no later than 30 days; see connection limits and reconnect timing.
Use the Python Agents SDK's HostedMCPTool to connect a server-side agent to ScriptHaul. Install openai-agents following OpenAI's SDK quickstart, and provide OPENAI_API_KEY through your runtime's secret configuration.
Connect your account
Supply SCRIPTHAUL_API_KEY from your secret store. This example exposes only get_transcript and authorizes fetching the single requested video, which costs at most one ScriptHaul credit. Model usage is billed separately by OpenAI.
import asyncio
import os
from agents import Agent, HostedMCPTool, Runner
async def main():
tool = HostedMCPTool(tool_config={
"type": "mcp",
"server_label": "scripthaul",
"server_url": "https://api.scripthaul.com/mcp",
"authorization": os.environ["SCRIPTHAUL_API_KEY"],
"allowed_tools": ["get_transcript"],
"require_approval": "never",
})
agent = Agent(
name="Caption reader",
instructions="Fetch only the requested video's captions. State the delivered language.",
tools=[tool],
)
result = await Runner.run(agent, "Fetch the transcript for jNQXAC9IVRw once.")
print(result.final_output)
asyncio.run(main())Here is the non-secret tool configuration as JSON. Add authorization from the environment at runtime as above:
{
"type": "mcp",
"server_label": "scripthaul",
"server_url": "https://api.scripthaul.com/mcp",
"allowed_tools": ["get_transcript"],
"require_approval": "never"
}For a multi-user app, complete OAuth registration, PKCE sign-in, and consent in your application, then supply that user's access token in authorization. The SDK does not perform your browser login for you. ScriptHaul's audience is https://api.scripthaul.com/mcp and its scope is mcp; discover endpoints at authorization metadata. Grants can create jobs and spend credits, but never see or create API keys; users revoke them in Dashboard → Connected apps.
The SDK wiring follows OpenAI's integrations guide. Authentication follows OpenAI's remote MCP guide. Verified 2026-09-05. Keep allowed_tools scoped to the task. Add search_youtube or create_bulk_job only when the user has authorized their credit cost.
Try without a ScriptHaul account
This configuration permits only free RSS reads and requires no ScriptHaul authorization value:
{
"type": "mcp",
"server_label": "scripthaul_taste",
"server_url": "https://scripthaul.com/mcp",
"allowed_tools": ["get_latest_videos"],
"require_approval": "never"
}import asyncio
from agents import Agent, HostedMCPTool, Runner
async def main():
agent = Agent(name="Latest uploads", tools=[HostedMCPTool(tool_config={
"type": "mcp",
"server_label": "scripthaul_taste",
"server_url": "https://scripthaul.com/mcp",
"allowed_tools": ["get_latest_videos"],
"require_approval": "never",
})])
result = await Runner.run(agent, "Show the newest videos from channel UC4QobU6STFB0P71PMvOGN5A.")
print(result.final_output)
asyncio.run(main())Keyless cold transcripts, if you enable that tool, are limited to 20 per address per UTC day; cloud callers may share an address. The account server supports search and durable bulk jobs: one credit per delivered search page or cold transcript, zero for cached transcripts, channel resolution, and latest uploads. See all tools and costs and the agent skill.