n8n-code-python

n8n-code-python is a skill for Claude Code, Codex from czlonkowski/n8n-mcp. It costs 228 tokens per session (3,005 once invoked), scanned A, original, MIT.

A guide to writing Python in n8n Code nodes, which are workflow steps where you can run custom code. It explains how to read incoming data, handle webhook data, and return results in n8n's required format.

In plain words
What is it for?
Writing Python transformations, processing workflow items, using Python's standard library, and working with data passed into n8n Code nodes.
Why use it?
It prevents common mistakes when using Python in n8n, including reading data from the wrong place or returning data in an invalid shape. It also explains when JavaScript may be a better choice.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Writing Python transformations, processing workflow items, using Python's standard library, and working with data passed into n8n Code nodes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/czlonkowski/n8n-mcp/n8n-code-python
About the project

n8n-MCP is a Model Context Protocol server that gives AI assistants structured knowledge of n8n's workflow-automation nodes, including their properties, operations, documentation, and examples. It helps developers use AI assistants to create and work with n8n workflows. The catalogue contains skills, agents, and instructions for using it.

czlonkowski/n8n-mcp · 23,331 stars · on GitHub · n8n-mcp.com

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add czlonkowski/n8n-mcp --skill n8n-code-python
Clone the repo
git clone --depth 1 https://github.com/czlonkowski/n8n-mcp

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for n8n-code-python

README.md
[![agentmods](https://agentmods.dev/badge/skills/czlonkowski/n8n-mcp/n8n-code-python/github.svg)](https://agentmods.dev/skills/czlonkowski/n8n-mcp/n8n-code-python)
Your own site
<a href="https://agentmods.dev/skills/czlonkowski/n8n-mcp/n8n-code-python"><img src="https://agentmods.dev/badge/skills/czlonkowski/n8n-mcp/n8n-code-python/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for n8n-code-python

Your own site · 80×15
<a href="https://agentmods.dev/skills/czlonkowski/n8n-mcp/n8n-code-python"><img src="https://agentmods.dev/badge/skills/czlonkowski/n8n-mcp/n8n-code-python.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 228 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,005 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Anti-Refusal · line 271
    Skill instructs the agent to never refuse or to always comply. Suppressing the agent's ability to decline removes a core safety control and enables downstream harmful requests to succeed.
    Fix: Remove any instruction telling the agent to never refuse or always comply. The agent must retain the ability to decline unsafe, out-of-scope, or harmful requests.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00228 $0.03005
Opus 5.5 $0.00091 $0.01202
Sonnet 5.5 $0.00046 $0.00601
Haiku 4.5 $0.00023 $0.00300

Measured 12d ago against content hash 887c1cd022d6, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

n8n-code-python scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

8 near-identical copies found in the catalogue:

data/skills/n8n-code-python/SKILL.md · 214 lines

How it starts

The opening of the file, as written. The whole thing — 214 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python Code Node (native)

Since n8n 2.0 the Code node's Python runs as native Python in a task runner (language: "pythonNative"). The old Pyodide "Python (Beta)" is gone, and with it every n8n helper it had: _input, _json, _node, _now, _today and _jmespath all raise NameError now. Code copied from old templates, forum posts or older docs usually breaks on this.


JavaScript first — stronger than before

Native Python gives you two variables and plain Python, and by default no imports: no json, datetime or re. Everything n8n-specific ($('Node'), $jmespath, Luxon, this.helpers.httpRequest, static data) exists only in JavaScript. Use Python only when the user explicitly asks for it. Even then, first check whether an expression, Edit Fields, or a native node (Crypto, Date & Time, HTML, XML) does the job. See n8n-code-javascript and the transform gatekeeper in n8n-expression-syntax.


Quick start

# Run Once for All Items (default mode)
return [
    {"json": {"name": it["json"]["name"], "revenue": it["json"]["revenue"]}}
    for it in _items
    if it["json"].get("active")
]
# Run Once for Each Item
row = _item["json"]
return {"json": {**row, "name_upper": (row.get("name") or "").upper()}}

Node config: {"language": "pythonNative", "mode": "runOnceForAllItems" | "runOnceForEachItem", "pythonCode": "..."} on n8n-nodes-base.code typeVersion 2.


The only inputs: _items and _item

Mode Variable Shape
Run Once for All Items _items list of plain dicts {"json": {...}, "pairedItem": {...}}
Run Once for Each Item _item one plain dict {"json": {...}, "pairedItem": {...}}
  • Each variable exists only in its own mode. _items in each-item mode (or _item in all-items mode) raises NameError.
  • Dict access only. it["json"]["name"] or it["json"].get("name"). it.json.name raises AttributeError: 'dict' object has no attribute 'json'.
  • No other nodes. There is no _node / $('Node') equivalent. If you need data from another branch, bring it in with Merge first, or read it in JavaScript.
  • Webhook payloads are under ["body"]: _items[0]["json"].get("body", {}).get("email").
  • Binary data isn't covered here. Read and write binary in JavaScript (see n8n-binary-and-data).
  • pairedItem: returning _items / _item keeps it. When you build new dicts and downstream uses $('Node').item, add "pairedItem": {"item": i} to each returned item. That isn't verified on native Python yet, so test-run before relying on it.
  • Missing keys: prefer .get(key, default). row["missing"] raises KeyError.

Read the full file on GitHub · 214 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago Changed · -288 lines · +71 tokens per session scan C → A 887c1cd022d6
  2. 3mo ago First seen · 502 lines · 157 tokens per session scan C cae740351f90

Subscribe to this mod's changes

n8n-code-python is a skill published in the GitHub repository czlonkowski/n8n-mcp (23,331 stars, last pushed yesterday), licensed MIT. It adds 228 tokens to every session and 3,005 once invoked, about $0.0009 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

n8n-code-python compared with skills from other repositories

n8n-code-python next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
n8n-code-pythonczlonkowski/n8n-mcpSkill23kyesterdayMITA228Claude Code, Codex
idapythonmrexodia/ida-pro-mcpSkill14k19d agoMITA77Claude Code
vibeuekevinpbuckley/VibeUESkill847yesterdayMITA0Claude Code, Codex
xeepy-python-twitter-guidenirholas/three.wsSkill289yesterdayApache-2.0A67Claude Code, Codex
python-api8beeeaaat/touchdesigner-mcpSkill6423d agoMITA117Claude Code
quantum-vqexi-zhao/OpenQuantumSkill752d agoMITA53Claude Code, Codex
quantum-vqlsxi-zhao/OpenQuantumSkill752d agoMITA56Claude Code, Codex