Connect
Python
Python is the fastest way to glue Dock into an existing pipeline. Two paths: hit the REST API with requests or httpx, or use the official MCP Python SDK for tool-calling.
Client
Python
Stdlib-friendly. Use requests for REST or the MCP SDK for tool-calling.
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+.
requestsorhttpxfor REST,mcpfor tool-calling.- A Dock
dk_key.
requests · read + write rowspython
import os, requests
API = "https://trydock.ai/api"
H = {"Authorization": f"Bearer {os.environ['DOCK_API_KEY']}"}
# List workspaces
ws = requests.get(f"{API}/workspaces", headers=H).json()
# Append a row
r = requests.post(
f"{API}/workspaces/content-pipeline/rows",
headers={**H, "Content-Type": "application/json"},
json={"data": {"title": "From Python", "status": "drafted"}},
)
r.raise_for_status()
row = r.json()
# Bulk-seal
requests.patch(
f"{API}/workspaces/content-pipeline/rows/bulk",
headers={**H, "Content-Type": "application/json"},
json={"updates": [{"id": row["id"], "data": {"status": "sealed"}}]},
).raise_for_status()httpx · SSE streampython
import os, httpx
async def stream_events():
headers = {"Authorization": f"Bearer {os.environ['DOCK_API_KEY']}"}
url = "https://trydock.ai/api/workspaces/content-pipeline/subscribe"
async with httpx.AsyncClient(timeout=None) as client:
async with client.stream("GET", url, headers=headers) as r:
async for line in r.aiter_lines():
if line.startswith("data: "):
print(line[6:])Verify
DOCK_API_KEY=dk_... python -c "import os, requests; \
print(requests.get('https://trydock.ai/api/me', \
headers={'Authorization': f'Bearer {os.environ[\"DOCK_API_KEY\"]}'}).json())"Troubleshooting
Symptom
Fix
SSL errors on requests
Upgrade
certifi: pip install --upgrade certifi.Wanting typed responses
Dock's OpenAPI spec lives at
https://trydock.ai/openapi.json. Generate typed clients with openapi-python-client or similar.Frequently asked questions
- How do I connect Dock to Python (from scratch)?
- Add Dock as a remote MCP server in Python (from scratch). Either let Python (from scratch)'s OAuth 2.1 + DCR flow handle auth (recommended; no credential ceremony), or paste a scoped Dock `dk_` API key in Python (from scratch)'s MCP config under the `Authorization: Bearer dk_…` header.
- Does Python (from scratch) 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 Python (from scratch), discovers them via the standard `tools/list` handshake. Learn more →
- How do I limit which Dock workspaces Python (from scratch) can write to?
- When you mint the `dk_` key for Python (from scratch) 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 Python (from scratch) did in my Dock workspace?
- Open the workspace in your browser. Every row Python (from scratch) 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 Python (from scratch) 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 Python (from scratch)'s `dk_` key in Settings → API keys.
- Can multiple Python (from scratch) sessions share state through Dock?
- Yes. Every Python (from scratch) 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 Python (from scratch) need OAuth or a dk_ API key for Dock?
- Either works. OAuth 2.1 + DCR is the recommended path: Python (from scratch) 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 call Dock's REST API from a Python script?
- Use `httpx` or `requests`: `httpx.get('https://trydock.ai/api/workspaces', headers={'Authorization': f'Bearer {os.environ["DOCK_API_KEY"]}'})`. Same Bearer pattern for every endpoint.
- How do I call Dock's MCP server from raw Python (no SDK)?
- Use `httpx` with HTTP transport for streamable JSON-RPC: `httpx.post('https://trydock.ai/api/mcp', headers={'Authorization': 'Bearer dk_...'}, json={'jsonrpc': '2.0', 'id': 1, 'method': 'tools/list'})`. SSE transport is similar with `httpx-sse`.
- How do I authenticate a Python cron job to Dock?
- Mint a `dk_` key for the cron in Settings → API keys. Store it in your secrets manager (1Password, Vault, AWS Secrets Manager). Inject it as `DOCK_API_KEY` env var at job runtime; never commit to source.