Connect
MCP TypeScript SDK
When you want raw control (custom agent loop, evals harness, backend integration), the MCP TypeScript SDK gives you a direct MCP client. Perfect for calling Dock tools from any Node process.
Client
MCP TypeScript SDK
Official @modelcontextprotocol/sdk (Node + browser).
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
- Node 20+.
@modelcontextprotocol/sdkinstalled (npm i @modelcontextprotocol/sdk).- A Dock
dk_key.
client.tstypescript
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
import { connectorFaqs } from "@/lib/connector-faqs";
const transport = new StreamableHTTPClientTransport(
new URL("https://trydock.ai/api/mcp"),
{
requestInit: {
headers: {
Authorization: `Bearer ${process.env.DOCK_API_KEY}`,
},
},
}
);
const client = new Client(
{ name: "my-agent", version: "1.0.0" },
{ capabilities: {} }
);
await client.connect(transport);
// List tools
const { tools } = await client.listTools();
console.log(`${tools.length} Dock tools available`);
// Call a tool
const result = await client.callTool({
name: "create_row",
arguments: {
slug: "content-pipeline",
data: { title: "From a script", status: "drafted" },
},
});
console.log(result.content);
await client.close();Verify
DOCK_API_KEY=dk_... npx tsx client.ts
# → 13 Dock tools available
# → { type: "text", text: "Created row row_01HX..." }Troubleshooting
Symptom
Fix
Transport hangs on connect
You may be behind a proxy that doesn't forward Mcp-Session-Id headers. Test with a direct network first. Dock uses the standard streamable-http transport shape; anything else implies a network-layer issue.
Tool calls return JSON-RPC error -32015
Plan cap hit. Read the
data field on the error object for the next-step endpoint (usually upgrade_plan or request_limit_increase).Frequently asked questions
- How do I connect Dock to MCP TypeScript SDK?
- Add Dock as a remote MCP server in MCP TypeScript SDK. Either let MCP TypeScript SDK's OAuth 2.1 + DCR flow handle auth (recommended; no credential ceremony), or paste a scoped Dock `dk_` API key in MCP TypeScript SDK's MCP config under the `Authorization: Bearer dk_…` header.
- Does MCP TypeScript 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 TypeScript SDK, discovers them via the standard `tools/list` handshake. Learn more →
- How do I limit which Dock workspaces MCP TypeScript SDK can write to?
- When you mint the `dk_` key for MCP TypeScript 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 TypeScript SDK did in my Dock workspace?
- Open the workspace in your browser. Every row MCP TypeScript 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 TypeScript 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 TypeScript SDK's `dk_` key in Settings → API keys.
- Can multiple MCP TypeScript SDK sessions share state through Dock?
- Yes. Every MCP TypeScript 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 TypeScript SDK need OAuth or a dk_ API key for Dock?
- Either works. OAuth 2.1 + DCR is the recommended path: MCP TypeScript 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 TypeScript SDK?
- Use `@modelcontextprotocol/sdk`: instantiate `Client` and `StreamableHTTPClientTransport` pointing at `https://trydock.ai/api/mcp` with your Bearer token. Call `client.connect(transport)` and `client.listTools()`.
- How do I handle OAuth 2.1 + DCR with the MCP TypeScript SDK against Dock?
- The SDK includes OAuth helpers in `src/client/auth.ts`. Pass an `OAuthClientProvider` instance to the transport; the SDK auto-discovers via Dock's `/.well-known/oauth-authorization-server` and registers as a client via `/api/oauth/register`.
- Can I use the TypeScript SDK to test Dock's tools before integrating into my agent?
- Yes. Write a small `node` script that connects, lists tools, and calls a few. Useful for smoke-testing your `dk_` key, exploring the tool surface, and validating multi-tool flows before wiring them into a production agent.