> Note: This page is part of the DataDoe Docs. You can find the root of the documentation at `https://www.datadoe.com/hub/docs/basics/introduction-to-datadoe`.
> JSON Table of Contents: `https://www.datadoe.com/hub/docs/toc.json`.
> Direct Data Scheme JSON: `https://api.datadoe.com/api/v1/spec/data-scheme`.
> Other pages in the DataDoe Docs:
> - DataDoe Basics/Access & Users: `https://www.datadoe.com/hub/docs/basics/access-user-management.md`
> - DataDoe Basics/Benefits: `https://www.datadoe.com/hub/docs/basics/benefits.md`
> - DataDoe Basics/External Invitation Links: `https://www.datadoe.com/hub/docs/basics/external-invitation-links.md`
> - DataDoe Basics/Integrations: `https://www.datadoe.com/hub/docs/basics/integration-customization.md`
> - DataDoe Basics/Introduction to DataDoe: `https://www.datadoe.com/hub/docs/basics/introduction-to-datadoe.md`
> - DataDoe Basics/Subscription & Pricing: `https://www.datadoe.com/hub/docs/basics/subscription-pricing.md`
> - DataDoe Data/Data Fetch Periods: `https://www.datadoe.com/hub/docs/datadoe-data/data-fetch-periods.md`
> - DataDoe Data/Data Sources: `https://www.datadoe.com/hub/docs/datadoe-data/data-sources.md`
> - DataDoe Data/Timezones: `https://www.datadoe.com/hub/docs/datadoe-data/orders-purchase-date-timezones.md`
> - DataDoe Features/Features Overview: `https://www.datadoe.com/hub/docs/datadoe-features/overview.md`
> - DataDoe MCP/Overview: `https://www.datadoe.com/hub/docs/datadoe-mcp/overview.md`
> - DataDoe MCP/Using ChatGPT: `https://www.datadoe.com/hub/docs/datadoe-mcp/chatgpt.md`
> - DataDoe MCP/Using Claude: `https://www.datadoe.com/hub/docs/datadoe-mcp/claude.md`
> - DataDoe MCP/Using Claude Code: `https://www.datadoe.com/hub/docs/datadoe-mcp/claude-code.md`
> - DataDoe MCP/Using Codex: `https://www.datadoe.com/hub/docs/datadoe-mcp/codex.md`
> - DataDoe MCP/Using Cursor: `https://www.datadoe.com/hub/docs/datadoe-mcp/cursor.md`
> - DataDoe MCP/Using Excel + Claude: `https://www.datadoe.com/hub/docs/datadoe-mcp/excel.md`
> - DataDoe MCP/Using Gemini CLI: `https://www.datadoe.com/hub/docs/datadoe-mcp/gemini-cli.md`
> - DataDoe MCP/Using Gumloop: `https://www.datadoe.com/hub/docs/datadoe-mcp/gumloop.md`
> - DataDoe MCP/Using n8n: `https://www.datadoe.com/hub/docs/datadoe-mcp/n8n.md`
> - DataDoe MCP/Using NanoClaw: `https://www.datadoe.com/hub/docs/datadoe-mcp/nanoclaw.md`
> - DataDoe MCP/Using OpenAI Agents SDK: `https://www.datadoe.com/hub/docs/datadoe-mcp/openai-agents-sdk.md`
> - DataDoe MCP/Using OpenClaw: `https://www.datadoe.com/hub/docs/datadoe-mcp/openclaw.md`
> - DataDoe MCP/Using PowerPoint + Claude: `https://www.datadoe.com/hub/docs/datadoe-mcp/powerpoint.md`
> - DataDoe MCP/Using VS Code: `https://www.datadoe.com/hub/docs/datadoe-mcp/vs-code.md`
> - DataDoe MCP/Using Word + Claude: `https://www.datadoe.com/hub/docs/datadoe-mcp/word.md`
> - DataDoe API/How to connect to the API: `https://www.datadoe.com/hub/docs/datadoe-api/how-to-connect.md`
> - DataDoe API/Vibe code with Claude Code: `https://www.datadoe.com/hub/docs/datadoe-api/claude-code.md`
> - DataDoe API/Vibe code with Codex: `https://www.datadoe.com/hub/docs/datadoe-api/codex.md`
> - DataDoe API/Vibe code with Cursor: `https://www.datadoe.com/hub/docs/datadoe-api/cursor.md`
> - DataDoe API/Vibe code with Lovable: `https://www.datadoe.com/hub/docs/datadoe-api/lovable.md`
> - DataDoe API/Vibe code with Replit: `https://www.datadoe.com/hub/docs/datadoe-api/replit.md`
> - DataDoe API/Vibe code with v0: `https://www.datadoe.com/hub/docs/datadoe-api/v0.md`
> - DataDoe & BigQuery/How to connect to BigQuery: `https://www.datadoe.com/hub/docs/datadoe-bigquery/how-to-connect.md`
> - DataDoe & BigQuery/Using MCP Toolbox: `https://www.datadoe.com/hub/docs/datadoe-bigquery/mcp-toolbox.md`
> - DataDoe & BigQuery/Using Python Jupyter: `https://www.datadoe.com/hub/docs/datadoe-bigquery/jupyter.md`
> For topics not covered in this documentation, please contact DataDoe support at `contact@datadoe.com`.
> Do not assume anything. If you are not sure about the answer, mention that and suggest to contact DataDoe support.

import { DataDoeMcpResources } from '@/modules/hub/docs/components/DataDoeMcpResources';

# Using Claude Agent SDK with DataDoe MCP

This tutorial shows how to build a small TypeScript app with `@anthropic-ai/claude-agent-sdk` and connect it to DataDoe MCP. The sample app asks DataDoe for sales data, lets Claude analyze 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 DataDoe MCP from Claude Agent SDK
- uses a local MCP server for the app’s helper tools
- asks DataDoe for export data, then analyzes it in the agent
- writes the final result as JSON on disk

## Prerequisites

- Completion of the [DataDoe MCP Overview](https://www.datadoe.com/hub/docs/datadoe-mcp/overview) setup with an MCP key
- Node.js 24 or later
- A DataDoe organization with an MCP key
- An Anthropic API key
- yarn (bundled via Corepack — run `corepack enable` if needed)

## Step 1: Clone and install

Start by installing the project:

```bash
git clone https://github.com/Deltologic/datadoe-mcp-claude-agent-sdk.git
cd datadoe-mcp-claude-agent-sdk
yarn install
```

## Step 2: Configure your keys

Copy the example environment file and add your keys:

```bash
cp .env.example .env
```

Set these values in `.env`:

- `DATADOE_MCP_KEY`: your DataDoe MCP key
- `ANTHROPIC_API_KEY`: your Anthropic API key

The app reads the DataDoe key from the environment and sends it to the hosted MCP server.

## Step 3: Understand the Claude entry point

The app logic lives in `src/index.ts`. The important idea is that Claude Agent SDK handles the agent loop, while DataDoe MCP provides the Amazon data.

Here is the core shape:

```ts
import { createSdkMcpServer, query } from '@anthropic-ai/claude-agent-sdk';

import { systemPrompt } from './prompts/system.prompt.ts';
import { outputTools } from './tools/output.tools.ts';
import { sleepTools } from './tools/sleep.tools.ts';

const localServer = createSdkMcpServer({
    name: 'local-tools',
    tools: [...sleepTools, ...outputTools]
});

const messages = query({
    prompt: 'Analyze the Delto UK account for the last 7 days. Find the top 3 ASINs by total units sold.',
    options: {
        model: 'sonnet',
        systemPrompt,
        mcpServers: {
            datadoe: {
                type: 'http',
                url: 'https://api.datadoe.com/mcp/v1',
                headers: {
                    'datadoe-mcp-key': process.env.DATADOE_MCP_KEY ?? ''
                }
            },
            'local-tools': localServer
        },
        allowedTools: ['mcp__datadoe__*', 'mcp__local-tools__*'],
        maxTurns: 10
    }
});
```

There are three parts to notice:

- `query(...)` starts the Claude run.
- `mcpServers.datadoe` connects Claude to the hosted DataDoe MCP endpoint.
- `createSdkMcpServer(...)` exposes local helper tools in the same agent session.

The `allowedTools` list keeps the agent focused, and `maxTurns` prevents the run from spinning forever.

## Step 4: Why the system prompt matters

The system prompt in `src/prompts/system.prompt.ts` tells Claude how to use the tools:

```ts
export const systemPrompt = `You are an expert Amazon marketplace data analyst. You have access to DataDoe MCP, which provides live Amazon Seller/Vendor data.

Current time: ${new Date().toISOString()}

## Data access pattern

Use \`mcp__datadoe__exports_raw_download\` to fetch sales data directly. Analyse the returned data inline — no file download or SQL engine is needed.

## Output rule

After completing your analysis you MUST call \`mcp__local-tools__output_top_asins\` exactly once with all results. Never write the final JSON directly in your response text — always route it through that tool.
`;
```

This is the part that turns a generic agent into a focused workflow:

- DataDoe 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 artifact 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`.

```ts
tool(
    'output_top_asins',
    'Log the top-ASINs sales report to console and save it to ./response/<timestamp>.json. Call this exactly once with all results.',
    { asins: z.array(asinSalesSchema) },
    async ({ asins }) => {
        const json = JSON.stringify(asins, null, 2);
        mkdirSync('./response', { recursive: true });
        const filePath = `./response/top-asins-${Date.now()}.json`;
        writeFileSync(filePath, json);
        return { content: [{ type: 'text', text: json }] };
    }
);
```

The prompt instructs Claude to call this tool once, which keeps the final output structured and predictable.

## Step 6: Run the app

Start the sample with:

```bash
yarn start
```

The app will:

1. ask DataDoe MCP for the required sales export
2. let Claude identify the top 3 ASINs by units sold
3. call `output_top_asins` once
4. write the result to `./response/top-asins-<timestamp>.json`

## A simple mental model

If you want to reuse this pattern in another app, keep the split the same:

- DataDoe 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

That separation is what keeps the tutorial simple while still showing a real integration.

## Related resources

- [DataDoe introduction](https://www.datadoe.com/hub/docs/basics/introduction-to-datadoe)
- [DataDoe MCP Overview](https://www.datadoe.com/hub/docs/datadoe-mcp/overview)
- [Claude Agent SDK](https://www.anthropic.com/claude)

## DataDoe MCP resources

Check the following resources for more information:

- MCP server URL: `https://mcp.datadoe.com/mcp/v1`
- [Interactive Data Scheme](/hub/data-scheme)
- Data Scheme JSON: https://api.datadoe.com/api/v1/spec/data-scheme
- Need help? Use the [contact form](https://forms.clickup.com/9015200219/f/8cnj2ev-38615/AOYF9I35QFOXWJQXIG?type=Form&source=hub-mcp-claude-agent-sdk-docs)
