Connect
Mastra
Mastra ships an MCP client out of the box. Construct an MCPClient pointing at Dock and every Mastra Agent gets the 13 Dock tools in its toolbelt.
Client
Mastra
TypeScript-first agent framework. First-class MCP client.
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+.
@mastra/mcpinstalled (npm i @mastra/mcp).- A Dock
dk_key.
agent.tstypescript
import { MCPClient } from "@mastra/mcp";
import { Agent } from "@mastra/core";
import { anthropic } from "@ai-sdk/anthropic";
import { connectorFaqs } from "@/lib/connector-faqs";
const mcp = new MCPClient({
servers: {
dock: {
url: new URL("https://trydock.ai/api/mcp"),
requestInit: {
headers: {
Authorization: `Bearer ${process.env.DOCK_API_KEY}`,
},
},
},
},
});
const tools = await mcp.getTools();
export const contentAgent = new Agent({
name: "ContentAgent",
instructions: "You help operate a shared Dock workspace.",
// Any Mastra-supported provider, anthropic(), openai(), google(), etc.
model,
tools,
});Verify
DOCK_API_KEY=dk_... npx mastra dev
# → Agent "ContentAgent" is ready with 63 tools from dockTroubleshooting
Symptom
Fix
Mastra dev shows 0 tools from dock
MCPClient rejects relative URLs. Pass new URL(...) not a plain string.Auth works in dev, fails in prod
Env vars don't always propagate through Mastra's prod bundler. Pass the Bearer header via a constant pulled at build time, or inject via a secrets manager.
Frequently asked questions
- How do I connect Dock to Mastra?
- Add Dock as a remote MCP server in Mastra. Either let Mastra's OAuth 2.1 + DCR flow handle auth (recommended; no credential ceremony), or paste a scoped Dock `dk_` API key in Mastra's MCP config under the `Authorization: Bearer dk_…` header.
- Does Mastra 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 Mastra, discovers them via the standard `tools/list` handshake. Learn more →
- How do I limit which Dock workspaces Mastra can write to?
- When you mint the `dk_` key for Mastra 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 Mastra did in my Dock workspace?
- Open the workspace in your browser. Every row Mastra 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 Mastra 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 Mastra's `dk_` key in Settings → API keys.
- Can multiple Mastra sessions share state through Dock?
- Yes. Every Mastra 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 Mastra need OAuth or a dk_ API key for Dock?
- Either works. OAuth 2.1 + DCR is the recommended path: Mastra 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 add Dock as an MCP server in Mastra?
- Use `@mastra/mcp-toolset` to wrap Dock: `new MCPClient({ servers: { dock: { url: 'https://trydock.ai/api/mcp', requestInit: { headers: { Authorization: 'Bearer dk_...' } } } } })`. Pass the client to your Mastra Agent's tools config.
- Can a Mastra workflow write to a Dock workspace at each step?
- Yes. Use Dock MCP tool calls inside Mastra workflow steps; each step appends to a Dock doc or table, giving you a durable audit trail of the workflow's state transitions.
- How does Dock fit Mastra's eval framework?
- Have your Mastra evals write results to a Dock table workspace (one row per eval run with score + reasoning columns). Your team can sort, filter, and comment on individual eval results in the Dock UI without writing custom dashboards.