Using Claude Agent SDK with Marrow MCP
This tutorial shows how to build a small TypeScript app with@anthropic-ai/claude-agent-sdk and connect it to Marrow MCP. The sample app asks Marrow for sales data, lets Claude analyse it, and writes a structured JSON report to ./response/.
What you will build
By the end, you will have a simple agent that:- connects to Marrow MCP from Claude Agent SDK
- uses a local MCP server for the app’s helper tools
- asks Marrow for export data, then analyses it in the agent
- writes the final result as JSON on disk
Prerequisites
- Completion of the Marrow MCP Overview setup with an MCP key
- Node.js 24 or later
- A Marrow organization with an MCP key
- An Anthropic API key
- yarn (bundled via Corepack - run
corepack enableif needed)
Step 1: Clone and install
Start by installing the project:Step 2: Configure your keys
Copy the example environment file and add your keys:.env:
MARROW_MCP_KEY: your Marrow MCP keyANTHROPIC_API_KEY: your Anthropic API key
Step 3: Understand the Claude entry point
The app logic lives insrc/index.ts. Claude Agent SDK handles the agent loop, while Marrow MCP provides the Amazon data.
Here is the core shape:
query(...)starts the Claude run.mcpServers.marrowconnects Claude to the hosted Marrow MCP endpoint.createSdkMcpServer(...)exposes local helper tools in the same agent session.
allowedTools list keeps the agent focused, and maxTurns stops the run from continuing forever.
Step 4: Why the system prompt matters
The system prompt insrc/prompts/system.prompt.ts tells Claude how to use the tools:
- Marrow MCP is the source of truth for the Amazon data
- Claude reasons over the returned data in the conversation
- the output tool writes one final JSON artefact to disk
Step 5: Keep the output step explicit
The app uses one local tool for the final handoff:output_top_asins in src/tools/output.tools.ts.
Step 6: Run the app
Start the sample with:- ask Marrow MCP for the required sales export
- let Claude identify the top 3 ASINs by units sold
- call
output_top_asinsonce - write the result to
./response/top-asins-<timestamp>.json
A simple mental model
To reuse this pattern in another app, keep the split the same:- Marrow MCP for Amazon data access
- Claude Agent SDK for the agent loop and tool orchestration
- local tools for file output and any small app-specific helpers
Related resources
Marrow MCP resources
Check the following resources for more information:- MCP server URL:
https://mcp.marrow.com/mcp/v1 - Interactive Data Scheme
- Data Scheme JSON: https://api.marrow.com/api/v1/spec/data-scheme
- Need help? Use the contact form

