agentsdk

n8n node for Claude Agent SDK integration with enhanced session management and MCP support

Package Information

Downloads: 1 weekly / 8 monthly
Latest Version: 0.1.1
Author: Anthropic

Documentation

n8n-nodes-agentsdk

This is an n8n community node that integrates Claude Agent SDK into n8n workflows with enhanced session management and MCP support.

Features

  • Autonomous Agent Execution: Run Claude Agent SDK operations directly in n8n workflows
  • Session Continuity: Resume conversations across workflow executions with continue operation
  • MCP Integration: Native support for Model Context Protocol servers
  • Tool Control: Granular control over which Claude tools are allowed/disallowed
  • Multiple Output Formats: Structured, messages, or plain text output
  • Project Path Support: Execute operations in specific project directories
  • Debug Mode: Comprehensive logging for troubleshooting

Installation

Community Nodes (Recommended)

  1. Go to Settings > Community Nodes in n8n
  2. Select Install
  3. Enter @anthropic/n8n-nodes-agentsdk
  4. Click Install

Manual Installation

# Navigate to n8n installation
cd ~/.n8n/nodes

# Clone repository
git clone https://github.com/anthropics/n8n-nodes-agentsdk.git

# Install dependencies
cd n8n-nodes-agentsdk
npm install

# Build
npm run build

# Restart n8n

Configuration

API Keys

Set your Anthropic API key as an environment variable:

export ANTHROPIC_API_KEY='your-api-key-here'

Or configure it in your n8n credentials settings.

MCP Servers (Optional)

To use MCP servers with Agent SDK:

  1. Create .mcp.json in your project root or user home directory
  2. Configure MCP servers (see MCP documentation)
  3. Agent SDK will automatically load configurations when running

Usage

Basic Query

  1. Add "Agent SDK" node to your workflow
  2. Select "Query" operation
  3. Enter your prompt
  4. Choose model (Sonnet/Opus)
  5. Configure output format
  6. Execute workflow

Continue Conversation

  1. Run initial query
  2. Add another Agent SDK node
  3. Select "Continue" operation
  4. Enter follow-up prompt
  5. Agent maintains conversation context

Advanced Configuration

Allowed/Disallowed Tools:

  • Select which built-in Claude tools to enable/disable
  • Disallowed tools take precedence over allowed

Project Path:

  • Set working directory for Agent SDK operations
  • Enables file access and command execution in specific locations

Additional Options:

  • Debug Mode: Enable detailed logging
  • Fallback Model: Automatic model switching on overload
  • Max Thinking Tokens: Control internal reasoning tokens
  • Permission Mode: Configure tool usage permissions
  • System Prompt: Add custom context/instructions

Examples

Code Analysis Workflow

Webhook Trigger → Agent SDK (Query: "Analyze this codebase") → Slack (Send Results)

Automated Code Review

GitHub Trigger → Agent SDK (Query: "Review PR #123") → Create Issue (if issues found)

Database Schema Generator

HTTP Request (Get Requirements) → Agent SDK (Query: "Generate SQL schema") → PostgresSQL (Execute)

Comparison with claude-code Package

Feature claude-code agent-sdk
Session Management Basic Enhanced
MCP Support Limited Native
Error Handling Standard Production-ready
Streaming Yes Improved
Performance Good Optimized

Development

# Clone repository
git clone https://github.com/anthropics/n8n-nodes-agentsdk.git
cd n8n-nodes-agentsdk

# Install dependencies
npm install

# Build
npm run build

# Development mode (watch)
npm run dev

# Format code
npm run format

# Lint
npm run lint

# Link for local testing
npm link
n8n start

Troubleshooting

Build Errors

# Clean and rebuild
npm run build

Node Not Appearing in n8n

  1. Verify installation in ~/.n8n/nodes
  2. Check n8n logs for errors
  3. Restart n8n completely
  4. Clear browser cache

API Key Issues

  • Verify ANTHROPIC_API_KEY environment variable
  • Check API key has proper permissions
  • Ensure n8n has access to environment variables

Debug Mode

Enable "Debug Mode" in Additional Options to get detailed execution logs in n8n.

Resources

License

MIT

Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Support


Version: 0.0.0-development
Last Updated: 2025-10-03

Discussion