Skip to main content

What Happens When You Deploy?

When you deploy a custom tool with deployCode, DataGen creates:
  • REST API Endpoint - Call your tool from any system via HTTP
  • MCP Tool - Use your tool directly in Claude and other MCP clients
  • Async Runner - Execute long-running tasks without timeouts

Deploying Your Tool

Via Natural Language

Ask Claude to deploy after you’ve tested your code:

Deployment Prompts

"Deploy this as a production API called 'enrich_leads'"
"Deploy this tool and make it available as both an API and MCP tool"
"Deploy this with parameters for batch_size and dry_run mode"

Via deployCode Tool

Claude will call deployCode with your configuration:
{
  "deployment_name": "enrich_leads",
  "description": "Enrich company data from domains",
  "script": "...",
  "input_schema": {
    "type": "object",
    "properties": {
      "domains": {"type": "array", "items": {"type": "string"}},
      "batch_size": {"type": "integer", "default": 10}
    },
    "required": ["domains"]
  },
  "output_variables": ["enriched_data", "total_count"],
  "mcp_server_names": ["Perplexity", "LinkedIn"],
  "required_secrets": ["OPENAI_API_KEY"]
}

Using Your Deployed Tool

As an MCP Tool

Once deployed, your tool appears in DataGen MCP. Ask Claude:
"Use my enrich_leads tool to process these 50 company domains"

As a REST API

Call your tool via HTTP:
curl -X POST "https://api.datagen.dev/v1/custom-tools/YOUR_TOOL_ID/run" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"domains": ["acme.com", "example.com"], "batch_size": 10}'

Via submitCustomToolRun

Run from Claude or other MCP clients:
"Run my enrich_leads tool with domains=['acme.com', 'example.com']"

Scheduling

Setting Up a Schedule

Ask Claude to schedule your deployed tool:

Scheduling Examples

Daily schedule:
"Schedule my crm_hygiene tool to run every day at 9 AM"
Weekly schedule:
"Run my weekly_report tool every Monday at 8 AM Pacific"
Custom CRON:
"Schedule this to run every 6 hours using cron expression"

Schedule Options

Schedule TypeExampleDescription
HourlyEvery hour0 * * * *
Daily9 AM daily0 9 * * *
WeeklyMonday 8 AM0 8 * * 1
CustomEvery 6 hours0 */6 * * *

With Payload

Pass parameters to scheduled runs:
{
  "schedule": "0 9 * * *",
  "payload": {
    "batch_size": 100,
    "dry_run": false,
    "notify_slack": true
  }
}

Monitoring Runs

Check Run Status

"Check the status of my last enrich_leads run"
Or use checkRunStatus with the run ID.

Run Statuses

StatusDescription
QueuedWaiting to start
RunningCurrently executing
CompletedFinished successfully
FailedEncountered an error

View Run History

"Show me the last 10 runs of my enrich_leads tool"

Managing Deployed Tools

Find Your Tools

"List all my deployed custom tools"
Or use searchCustomTools:
"Search for my enrichment tools"

Get Tool Details

"Show me the details of my enrich_leads tool including the webhook URL"
Use getCustomToolDetails to see:
  • API endpoint URL
  • Input/output schemas
  • Dependencies
  • Recent runs

Update a Tool

"Update my enrich_leads tool to also return industry classification"
Use updateCustomTool to modify:
  • Python code
  • Input/output schemas
  • Dependencies
  • Name and description

Integration Patterns

Webhook Trigger

Use the webhook URL to trigger from external systems:
# Trigger from Zapier, n8n, or custom apps
curl -X POST "https://api.datagen.dev/webhook/YOUR_WEBHOOK_ID" \
  -H "Content-Type: application/json" \
  -d '{"domains": ["newlead.com"]}'

Chaining Tools

Call one custom tool from another:
from datagen_sdk import DatagenClient

client = DatagenClient()

# First tool: enrich the data
enriched = client.execute_tool("custom_enrich_leads", {
    "domains": input_domains
})

# Second tool: push to CRM
result = client.execute_tool("custom_push_to_hubspot", {
    "leads": enriched
})

Error Handling

from datagen_sdk import DatagenClient, DatagenToolError

client = DatagenClient()

try:
    result = client.execute_tool("mcp_Linear_create_issue", {...})
except DatagenToolError as e:
    # Log error and continue
    error_log.append({"error": str(e), "input": input_data})
    result = None

What’s Next?

Create Custom Tools

Learn how to write custom tool code

Deploy Agents

Run Claude Code agents on schedule

Connect MCPs

Add more MCP servers

Built-in Tools

Explore pre-built integrations