Connect
MCP Python SDK
For custom Python agents, eval runs, and CI scripts: call Dock's MCP directly via the official MCP Python SDK. No framework needed.
Client
MCP Python SDK
Official mcp package. Streamable-http and SSE transports.
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+.
mcpinstalled (pip install mcp).- A Dock
dk_key.
client.pypython
import asyncio, os
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
async def main():
async with streamablehttp_client(
"https://trydock.ai/api/mcp",
headers={"Authorization": f"Bearer {os.environ['DOCK_API_KEY']}"},
) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await session.list_tools()
print(f"{len(tools.tools)} Dock tools available")
result = await session.call_tool(
"create_row",
arguments={
"slug": "content-pipeline",
"data": {"title": "From Python", "status": "drafted"},
},
)
print(result.content)
asyncio.run(main())Verify
DOCK_API_KEY=dk_... python client.py
# → 13 Dock tools available
# → [TextContent(text='Created row row_01HX...')]Troubleshooting
Symptom
Fix
ImportError: streamablehttp_client not found
Upgrade the
mcp package to 1.0+. Older builds only shipped SSE.SSL / certificate errors on connect
Your Python install uses a stale CA bundle. Install
certifi and set SSL_CERT_FILE=$(python -m certifi) before running.Frequently asked questions
- How do I connect Dock to MCP Python SDK?
- Add Dock as a remote MCP server in MCP Python SDK. Either let MCP Python SDK's OAuth 2.1 + DCR flow handle auth (recommended; no credential ceremony), or paste a scoped Dock `dk_` API key in MCP Python SDK's MCP config under the `Authorization: Bearer dk_…` header.
- Does MCP Python 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 MCP Python SDK, discovers them via the standard `tools/list` handshake. Learn more →
- How do I limit which Dock workspaces MCP Python SDK can write to?
- When you mint the `dk_` key for MCP Python 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 MCP Python SDK did in my Dock workspace?
- Open the workspace in your browser. Every row MCP Python 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 MCP Python 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 MCP Python SDK's `dk_` key in Settings → API keys.
- Can multiple MCP Python SDK sessions share state through Dock?
- Yes. Every MCP Python 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 MCP Python SDK need OAuth or a dk_ API key for Dock?
- Either works. OAuth 2.1 + DCR is the recommended path: MCP Python 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 connect to Dock's MCP server from the Python SDK?
- Use `mcp` package's `streamablehttp_client` or `sse_client`: `async with streamablehttp_client('https://trydock.ai/api/mcp', headers={'Authorization': 'Bearer dk_...'}) as session: tools = await session.list_tools()`.
- How do I handle OAuth 2.1 + DCR with the MCP Python SDK against Dock?
- The SDK ships an OAuth client provider in `mcp.client.auth`. Pass it to your client constructor; it handles discovery via `/.well-known/oauth-authorization-server`, DCR via `/api/oauth/register`, and token refresh automatically.
- Can I bridge a custom Python agent to Dock without using a framework?
- Yes, use the MCP Python SDK directly. Connect, list tools, call them based on your agent's loop. Useful when you've built a custom agent loop (cron, FastAPI handler, queue worker) and don't want a framework dependency.