Connect
openai-agents-sdk logo

OpenAI Agents SDK

The OpenAI Agents SDK has a built-in MCPServer helper. Wire up Dock, hand the server to an Agent, done.

Client
OpenAI Agents SDK
Python + JS. First-class MCPServer class.
HTTP JSON-RPC (streamable-http)
Dock MCP
trydock.ai/api/mcp
37 tools · OAuth 2.1 + DCR · Bearer
Auth path
1
Mint a dk_ key in Dock Settings → API keys.
2
Paste it as Authorization: Bearer dk_… in the client config.
3
Client calls Dock MCP directly on every request.

Prerequisites

  • Python 3.10+ or Node 20+.
  • openai-agents installed (pip install openai-agents or npm i @openai/agents).
  • A Dock dk_ key.
Pythonpython
import os
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp

dock = MCPServerStreamableHttp(
    params={
        "url": "https://trydock.ai/api/mcp",
        "headers": {
            "Authorization": f"Bearer {os.environ['DOCK_API_KEY']}"
        },
    }
)

async def main():
    async with dock:
        agent = Agent(
            name="Content agent",
            instructions="You manage the content-pipeline workspace.",
            mcp_servers=[dock],
        )
        result = await Runner.run(agent, "List my workspaces.")
        print(result.final_output)
TypeScripttypescript
import { Agent, run } from "@openai/agents";
import { MCPServerStreamableHttp } from "@openai/agents/mcp";
import { connectorFaqs } from "@/lib/connector-faqs";

const dock = new MCPServerStreamableHttp({
  url: "https://trydock.ai/api/mcp",
  headers: {
    Authorization: `Bearer ${process.env.DOCK_API_KEY}`,
  },
});

await dock.connect();

const agent = new Agent({
  name: "Content agent",
  instructions: "You manage the content-pipeline workspace.",
  mcpServers: [dock],
});

const result = await run(agent, "List my workspaces.");
console.log(result.finalOutput);

await dock.close();

Verify

DOCK_API_KEY=dk_... python agent.py
# → Found 3 workspaces: content-pipeline, research-queue, product-brief

Troubleshooting

Symptom
Fix
Agent can't discover MCP tools
Make sure you connected the server before running. In Python, use async with dock:. In JS, await dock.connect().
Streamable-http class not found
Some older builds only ship SSE transport. Upgrade the package, or switch to MCPServerSse with the same trydock.ai/api/mcp URL (Dock responds to both).

Frequently asked questions

How do I connect Dock to OpenAI Agents SDK?
Add Dock as a remote MCP server in OpenAI Agents SDK. Either let OpenAI Agents SDK's OAuth 2.1 + DCR flow handle auth (recommended; no credential ceremony), or paste a scoped Dock `dk_` API key in OpenAI Agents SDK's MCP config under the `Authorization: Bearer dk_…` header.
Does OpenAI Agents SDK work with Dock's MCP server?
Yes. Dock exposes 43 MCP tools at `https://trydock.ai/api/mcp` over HTTP transport with OAuth 2.1 + DCR and Bearer-token auth. Any MCP-spec-compliant client, including OpenAI Agents SDK, discovers them via the standard `tools/list` handshake. Learn more →
How do I limit which Dock workspaces OpenAI Agents SDK can write to?
When you mint the `dk_` key for OpenAI Agents SDK in Settings → API keys, pick the workspace from the dropdown. The key returns 403 on every other workspace regardless of what the prompt asks. To scope across multiple, mint multiple keys or add the agent as an explicit member of each. Learn more →
How do I see what OpenAI Agents SDK did in my Dock workspace?
Open the workspace in your browser. Every row OpenAI Agents SDK created or updated is stamped with the agent's identity (orb + name) in the createdBy / updatedBy field. The workspace activity feed shows every action chronologically. Learn more →
How do I undo a row OpenAI Agents SDK wrote to Dock?
Open the row, click the kebab menu, choose Delete (soft-delete preserves history). For bulk reverts use the activity feed to find the agent's session and delete its rows in batch. To prevent future writes, revoke OpenAI Agents SDK's `dk_` key in Settings → API keys.
Can multiple OpenAI Agents SDK sessions share state through Dock?
Yes. Every OpenAI Agents SDK session reads and writes the same workspace, so handoffs across machines or across long-running multi-session workflows just work. The Dock workspace IS the shared state; no separate message bus required.
Does OpenAI Agents SDK need OAuth or a dk_ API key for Dock?
Either works. OAuth 2.1 + DCR is the recommended path: OpenAI Agents SDK hits Dock's discovery endpoint at `/.well-known/oauth-authorization-server` and auto-registers as a client. The `dk_` Bearer token path is fine for owned-code agents and CI scripts; pick whichever fits your stack. Learn more →
How do I use Dock with the OpenAI Agents SDK?
Use the SDK's `MCPServerHttp` adapter pointing at `https://trydock.ai/api/mcp` with your `dk_` Bearer header. Pass the resulting MCPServer instance to `Agent(mcp_servers=[dock])` and the 43 Dock tools become available to the agent. Learn more →
Can OpenAI Agents SDK agents share state via Dock?
Yes. Multiple agent instances connecting to the same Dock workspace via MCP share workspace state in real time. No need for an external state store; Dock is the state.
How does Dock's auth model fit OpenAI Agents SDK's per-agent identity?
Mint one `dk_` key per OpenAI Agents SDK agent in Settings → API keys (each scoped to the workspace it should access). Pass each key into the agent's MCPServer config. Attribution in Dock then matches each agent's writes correctly.

Related

Updated