Skip to content

feat: add N8nTools toolkit for n8n workflow automation - #7339

Open
AlsoTheZv3n wants to merge 2 commits into
agno-agi:mainfrom
AlsoTheZv3n:feat/n8n-tools
Open

AlsoTheZv3n wants to merge 2 commits into
agno-agi:mainfrom
AlsoTheZv3n:feat/n8n-tools

Conversation

@AlsoTheZv3n

Copy link
Copy Markdown

Summary

Adds N8nTools — a toolkit for interacting with self-hosted n8n workflow
automation instances via the n8n REST API v1.

Closes #7338

What was added

  • libs/agno/agno/tools/n8n.py — N8nTools class with 7 sync + 7 async methods:
    • list_workflows / alist_workflows (with active_only filter, limit/cursor pagination)
    • get_workflow / aget_workflow
    • activate_workflow / aactivate_workflow
    • deactivate_workflow / adeactivate_workflow
    • list_executions / alist_executions (with workflow_id filter, limit/cursor pagination)
    • get_execution / aget_execution
    • delete_execution / adelete_execution
  • libs/agno/pyproject.toml — n8n optional extra added + entry in tools list
  • cookbook/91_tools/n8n_tools.py — cookbook example showing an agent monitoring n8n workflows

Pattern followed

Built following the same patterns as:

  • GitlabTools — REST API + async httpx + flag-based registration + async_tools tuples
  • SerpApiTools — API key handling via getenv() + all flag

Type of change

  • New feature

Checklist

  • Code complies with style guidelines
  • Ran format/validation scripts (./scripts/format.sh and ./scripts/validate.sh)
  • Self-review completed
  • Documentation updated (comments, docstrings)
  • Examples and guides: Relevant cookbook examples have been included or updated
  • Tested in clean environment
  • Tests added/updated (if applicable)

Duplicate and AI-Generated PR Check

  • I have searched existing open pull requests and confirmed that no other PR already addresses this issue
  • If a similar PR exists, I have explained below why this PR is a better approach
  • Check if this PR was entirely AI-generated (by Copilot, Claude Code, Cursor, etc.)

Testing

  • Tested locally against n8n (Docker, latest version) with full API key scopes
  • All 7 sync + 7 async methods verified against live n8n instance
  • Edge cases tested: invalid API key (401), offline server (connection error), non-existent IDs (404)
  • Pagination verified with limit/cursor across multiple pages
  • all flag verified to override individual enable_* flags
  • All responses are JSON strings, no exceptions thrown to caller
  • ./scripts/format.sh — 0 errors
  • ./scripts/validate.sh (ruff check) — 0 errors

Additional Notes

  • httpx is already a core dependency of agno, so no additional package installation is needed
  • The n8n REST API v1 uses cursor-based pagination; both list_workflows and list_executions expose limit and cursor parameters and return nextCursor in the response
  • This PR was generated with assistance from Claude Code

Adds N8nTools — a toolkit for interacting with self-hosted n8n
instances via the n8n REST API v1.

Methods (7 sync + 7 async):
- list_workflows / alist_workflows (with active_only filter and pagination)
- get_workflow / aget_workflow
- activate_workflow / aactivate_workflow
- deactivate_workflow / adeactivate_workflow
- list_executions / alist_executions (with workflow_id filter and pagination)
- get_execution / aget_execution
- delete_execution / adelete_execution

Files:
- libs/agno/agno/tools/n8n.py — N8nTools class
- libs/agno/pyproject.toml — n8n optional extra
- cookbook/91_tools/n8n_tools.py — cookbook example

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@AlsoTheZv3n
AlsoTheZv3n requested a review from a team as a code owner April 4, 2026 11:58
@github-actions

github-actions Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

PR Triage

Missing tests: This PR modifies source code but does not include any test changes. Please add or update tests to cover your changes.

35 tests covering:
- Init (explicit params, env var, no key, trailing slash)
- Flag registration (defaults, selective, all flag, no flags)
- Async tool name mapping
- Helper methods (URL building, headers, error formatting)
- All 7 sync methods (happy path + pagination)
- Error handling (401, 404, connection error)
- 6 async methods (happy path + error handling)
- aclose() behavior

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale due to 14 days of inactivity. If this is still relevant, please update it or leave a comment.

@github-actions github-actions Bot added the stale label Apr 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add N8nTools toolkit for n8n workflow automation

1 participant