Version 0.1.1 · MIT license
Extend Total.js with Python, Rust, Go and WebAssembly.
Call functions written in other languages from Total.js and Node.js as plain async functions. Turn them into actions, API endpoints and MCP tools for AI agents, without leaving JavaScript.
# python/sentiment.py
from totalfusion import action
@action(summary='Detects the sentiment of a text',
input='*text:String', output='label:String', mcp=True)
def analyze(data):
return { 'label': 'POSITIVE' if 'love' in data['text'] else 'NEGATIVE' }// Total.js application
const fusion = REQUIRE('totalfusion');
fusion.register({ python: { path: PATH.root('python') } });
// An action, an API route and an MCP tool
const result = await ACTION('sentiment/analyze', { text: 'I love it' }).promise();Four runtimes, one way to call them
Pick the language that fits the work. The call from JavaScript is always the same.
Python
Machine learning, scientific computing, any Python library. Python 3.9 or newer.
Python docs →Rust
Speed, many threads and a small footprint. You build a binary; running it does not need Rust.
Rust docs →Go
Network and infrastructure code, many calls at once, one binary for any system.
Go docs →WebAssembly
Code in a sandbox: no files, no network, no environment, in one file for every system.
WebAssembly docs →From zero to a first call in a minute
Node.js 20 or newer, and Python 3.9 or newer for the Python runtime. TotalFusion never installs, downloads or compiles anything for you.
Install it
npm install totalfusion
npx totalfusion doctor --path ./pythonThe doctor tells you what is missing, and the exact command to fix it, before anything runs.
Write the function
# python/hello.py
def greet(data):
return {'message': 'Hello ' + data['name']}A plain function in a plain file. No server, no protocol.
Call it from Node.js
const fusion = require('totalfusion');
fusion.configure({
python: { path: './python' }
});
const result = await fusion.python(
'hello.greet', { name: 'world' });
// { message: 'Hello world' }A pool of workers starts on the first call and stays alive.
Keep going in Getting started: it covers Total.js 5 actions, Rust, Go and the doctor.
Why not just child_process?
A process per call costs time and gives you nothing to build on. A worker that is already running answers at once, and keeps your model in memory.
Beyond speed you get what you would otherwise write yourself: a pool, a bounded queue, timeouts, cancellation, restart of workers that die, memory limits, streaming and the contracts that make a function an action. Use cases has the numbers, and where it does not fit says when not to use it.
What you get
Workers that stay healthy
A pool of long-lived processes that Node.js supervises: timeouts, cancellation, real errors, replaced after a number of calls or when they use too much memory. A crash never takes your application down.
Total.js integration
Functions that declare a contract become actions with validated input, permissions, API routes, MCP tools and Server-Sent Events.
A sandbox
A WebAssembly module runs without files, network or environment. Load the code of third parties and cut off one that never returns.
Seven components for Flow
Call a function of any runtime from a node, stream chunks as messages, send the events of the workers to an alert and read the stats.
Streaming
A generator in Python or a stream function in Rust or Go is an async iterable, with backpressure and cancellation.
Binary data without base64
Buffer and typed arrays travel as raw bytes in both directions, NumPy arrays included.
Development reload
Save a file and the next call runs the new code. A doctor checks your setup before anything runs.
Made for AI assistants
Your functions as MCP tools, JSON schemas, and files for models and agents: llms.txt and AGENTS.md.
Honest about security
The documentation says what it protects and what it does not.
Learn by building
Every tutorial has an application that you can run and a test that runs it on every change, so the commands and the answers on the page are the ones that work.
A Python function as an API and as a tool for an AI agent
Write a function with a contract, serve it from Total.js with validation, offer it to an agent over MCP and edit it while it runs.
Tutorial 1 →Run the code of third parties in the sandbox of WebAssembly
Load modules of customers, watch a hostile one fail to read files, and cut off one that never returns.
Tutorial 2 →