mcpField
N
n8n-code-python

n8n-code-python

github.com/sickn33Development49.2k203 installsUpdated today
Repository

About n8n-code-python

A guidance skill for using Python in n8n Code nodes for bounded data transformations. It explains the native runtime contract, version caveats, and safe deployment practices rather than providing a workflow or runner.

Key features

  1. 01All-items and per-item patterns
  2. 02Native Python runtime caveats
  3. 03Import and allowlist constraints
  4. 04Input and execution safety guidance
  5. 05Item linking and output limitations

Use cases

  1. 01Transforming items in an n8n Code node
  2. 02Migrating code to the native Python runtime
  3. 03Checking import and runner constraints

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/sickn33/agentic-awesome-skills --skill n8n-code-python

After installing, type/n8n-code-pythonin Claude Code to confirm it loaded.

Bundled filesreferences/detailed-guide.md

Details

From the project README

Python Code Node (Native)

When to Use

Use for bounded Python transformations in an n8n Code node when native nodes or expressions are insufficient. Check the installed n8n version and task runner first.

Runtime contract

n8n 2 removed the legacy Pyodide runtime. Native Python uses _items in all-items mode and _item in per-item mode; legacy _input, _json, _node and _now helpers are unavailable. Self-hosted imports depend on installed runner packages and explicit allowlists. Cloud imports may be unavailable, including standard modules. JavaScript imports are restricted too; switching languages does not provide unrestricted filesystem, networking or package access.

Examples

All-items mode, with no imports:

return [
    {"json": {"id": item["json"].get("id"), "processed": True},
     "pairedItem": {"item": index}}
    for index, item in enumerate(_items)
    if item["json"].get("active")
]

Per-item mode:

return {"json": {**_item["json"], "name_upper": (_item["json"].get("name") or "").upper()}}

Validate actual input types before string operations. Use HTTP Request nodes with managed credentials for remote calls and enforce allowed destinations. Do not log payloads/tokens or execute code supplied by webhook users. Keep item count, input size and runtime bounded; prepare changes in an inactive test workflow before activating workflows that send messages, spend money or modify external systems.

Detailed Guide

Read the guide for transformation patterns and migration caveats. The referenced upstream auxiliary files are not bundled.

Limitations

No workflow or runner is included. Import availability and output normalization must be checked in the deployed version; item linking, binary data and aggregation require explicit handling. No runtime tests are established by these examples.

Primary runtime reference: n8n Code node documentation source.

Comments

Markdown supported