Connect
Vercel AI SDK
The Vercel AI SDK can pull Dock's tools into any generateText or streamText call via the experimental MCP client.
Client
Vercel AI SDK
TypeScript SDK for agent apps. MCP via experimental_createMCPClient.
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+.
aiand@ai-sdk/anthropicinstalled (npm i ai @ai-sdk/anthropic).- A Dock
dk_key.
agent.tstypescript
import { experimental_createMCPClient as createMCPClient, generateText } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
import { connectorFaqs } from "@/lib/connector-faqs";
const dock = await createMCPClient({
transport: {
type: "http",
url: "https://trydock.ai/api/mcp",
headers: {
Authorization: `Bearer ${process.env.DOCK_API_KEY}`,
},
},
});
const tools = await dock.tools();
const { text } = await generateText({
// Any Vercel AI SDK provider, anthropic(), openai(), google(), etc.
model,
prompt: "List my Dock workspaces.",
tools,
maxSteps: 5,
});
console.log(text);
await dock.close();Verify
DOCK_API_KEY=dk_... npx tsx agent.ts
# → Found 3 workspaces: content-pipeline, research-queue, product-briefTroubleshooting
Symptom
Fix
Import fails: experimental_createMCPClient not exported
Upgrade
ai to a recent version (4.x+). MCP client support moved out of experimental in mid-2025; the name may be createMCPClient on newer builds.streamText stalls after first tool call
maxSteps defaults to 1. Set it to at least 5 for multi-step agent loops that include Dock tool calls.Frequently asked questions
- How do I connect Dock to Vercel AI SDK?
- Add Dock as a remote MCP server in Vercel AI SDK. Either let Vercel AI SDK's OAuth 2.1 + DCR flow handle auth (recommended; no credential ceremony), or paste a scoped Dock `dk_` API key in Vercel AI SDK's MCP config under the `Authorization: Bearer dk_…` header.
- Does Vercel AI 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 Vercel AI SDK, discovers them via the standard `tools/list` handshake. Learn more →
- How do I limit which Dock workspaces Vercel AI SDK can write to?
- When you mint the `dk_` key for Vercel AI 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 Vercel AI SDK did in my Dock workspace?
- Open the workspace in your browser. Every row Vercel AI 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 Vercel AI 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 Vercel AI SDK's `dk_` key in Settings → API keys.
- Can multiple Vercel AI SDK sessions share state through Dock?
- Yes. Every Vercel AI 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 Vercel AI SDK need OAuth or a dk_ API key for Dock?
- Either works. OAuth 2.1 + DCR is the recommended path: Vercel AI 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 Vercel AI SDK?
- Use `@ai-sdk/mcp` (or roll your own with `experimental_createMCPClient`): point at `https://trydock.ai/api/mcp` with the Bearer header. Pass the resulting tools to `streamText({ tools })` or `generateText({ tools })`.
- Can a Next.js app stream agent outputs to a Dock workspace?
- Yes. Inside your AI SDK route handler, on each tool-call result, call Dock's `append_doc_section` or `create_row`. Your end-user sees the streaming response in the browser; your team sees the durable artifacts in Dock.
- How do I attribute Vercel AI SDK calls to a specific Dock agent?
- Mint a per-agent `dk_` key (one per AI SDK app, or per user if multi-tenant). Pass it to the MCP client. Every Dock write is then attributed to that agent identity in the workspace activity feed.