Skip to main content

elabftw-toolkit

PyPI Python Docs License

An unofficial Python toolkit for working with eLabFTW Experiments and Resources (Database items). Common tasks like creating entries from templates, reading and writing fields, attaching files, linking, setting permissions, and locking take just a few lines of code.

📖 Documentation (user guide, cheat sheet, recipes): https://jasri-jp.github.io/elabftw-toolkit/en/

日本語 / User guide / Documentation site

This project is independent of eLabFTW and its official SDKs. Behavior can vary with your eLabFTW version and settings, so try it on test entries before using it in production.

What it does

  • Create: create Experiments and Resources from templates (body, fields, Steps, and permissions carry over)
  • Read and write: use field values like a dict, for example entry.fields["purity"]
  • Find: get lists as a table (DataFrame) or every entry as JSON, search by condition, or look up by title
  • Attach: attach files (skipping identical ones), download in bulk, add images to the body, and export as PDF, ELN, or JSON
  • Link and manage: links between entries, tags, permissions, locks and timestamps, body tables, and Steps
  • Write safely: try changes without writing (dry run), validate with a schema, prevent duplicates, and record who changed what
  • Export: export to MaiML (JIS K 0200) (requires an extra install)

Installation

Python 3.10 or later is required. Tested with eLabFTW 6.0.x (6.0.6), using REST API v2.

python -m pip install elabftw-toolkit            # basic
python -m pip install "elabftw-toolkit[maiml]"   # also for MaiML export
python -m pip install "elabftw-toolkit[mcp]"     # also for the MCP server (Claude Desktop and others)
python -m pip install "elabftw-toolkit[benten]"  # also for BENTEN metadata (YAML, Excel)

For development (editing the source while using it), clone and use an editable install:

git clone https://github.com/jasri-jp/elabftw-toolkit.git
cd elabftw-toolkit
python -m pip install -e ".[maiml,mcp,benten]"

Configuration

Set your eLabFTW server and API key as environment variables.

ELABFTW_HOST_URL="https://your-elabftw.example.jp"
ELABFTW_API_KEY="your-api-key"
  • To keep your API key in a file, use ELABFTW_KEY_FILE="/path/to/api_key.txt" instead of ELABFTW_API_KEY.
  • .env files aren't loaded automatically. If you use one, call from dotenv import load_dotenv; load_dotenv() first.
  • For passing settings as arguments and SSL options, see 1. Getting started.

Try it in five minutes

import elabftw_toolkit

elab = elabftw_toolkit.client("your-team-name")

# Find a sample by title and open it
sample = elab.items.find("TEST_SAMPLE", category_title="Sample")
entry = elab.items.entry(sample.id)

# Read and write fields
print(entry.fields["purity"])
entry.fields.update({"purity": "99.9%", "form": "powder"})

# Edit a locked entry by unlocking it temporarily (the lock is restored afterwards)
with entry.unlocked():
    entry.fields["purity"] = "99.99%"

# Attach a file (skipped if the same file is already there)
entry.files.upload("coa.pdf")

# Create an Experiment from a template and link it to the sample
exp_id = elab.experiments.init(
    title="2026T0001-XAFS-TEST_SAMPLE",
    template_name="Measurement test",
    category_id=elab.experiments.categories.id("Measurement"),
)
elab.experiments.entry(exp_id).set_item_field_and_link(
    field_name="sample_id", item_title="TEST_SAMPLE", item_category_title="Sample",
)

Names like "Sample", "Measurement", and "Measurement test" are examples. Use the names set up in your eLabFTW.

Command line

Command What it does More
elabftw-mcp Start the MCP server (needs [mcp]) 16. MCP server
python -m elabftw_toolkit.maiml check <folders…> Check MaiML files and the links between them (needs [maiml]) 10. MaiML export
python -m elabftw_toolkit.maiml graph <folders…> Draw the links between MaiML files in several places as a Mermaid diagram 10. MaiML export
python -m elabftw_toolkit.benten_schema check <folder> Check BENTEN metadata (metadata.all.yml) against the schema (needs [benten]) 16. MCP server

Every command lists its arguments with --help.

MCP server (use it from Claude and other AI assistants)

Register elabftw-mcp in Claude Desktop or another MCP client, and the AI can read and write eLabFTW.

Kind Tools
Read (10) list_categories, list_entries, get_entry, load_schema, validate_entry, get_structured_metadata, validate_structured_metadata, read_maiml, check_maiml, maiml_graph
Write (10) create_entry, update_fields, set_body, add_tags, update_status, add_link, upload_file, set_structured_metadata, lock_entry, unlock_entry
  • With ELABFTW_READ_ONLY=1, all write tools are disabled (previews with dry_run=true still work).
  • Write tools other than lock_entry / unlock_entry return only "old value → new value" with dry_run=true, and record the reason as a comment on the entry with reason="…".
  • For setup and each tool's arguments, see 16. MCP server.

User guide

If you want to Read
Get started 1. Getting started, 12. Troubleshooting
Read and find entries 2. Entries and fields, 3. Listing and search
Create, attach, and link 4. Creating entries and templates, 5. Files and images, 6. Links and tags
Permissions, locks, and body tables 7. Permissions, 8. Lock and timestamp, 9. HTML tables and steps
Work in bulk and export 11. Recipes, 10. MaiML export
Write safely 15. Validation and plans
Look up functions or update old scripts 14. API reference
Contribute 13. Testing and development
Use it from Claude or other AI assistants, work with AI 16. MCP server, 17. Working with AI

Documentation site

Published at https://jasri-jp.github.io/elabftw-toolkit/en/ (rebuilt by GitHub Actions on every push to main; .github/workflows/docs.yml).

The same guide can be read in a browser together with an introduction for new users, a cheat sheet, and recipes (VitePress; needs Node.js).

npm install
npm run dev      # import the guide and open http://localhost:5173
npm run build    # write HTML to docs/.vitepress/dist/

On Windows, double-click docs_preview.bat: it imports the guide and opens it in your browser (needs Node.js). To work inside sync folders such as Google Drive, it copies the site to %USERPROFILE%\.cache\elabftw-toolkit-docs and runs it there (the first run installs VitePress and takes a little longer). After editing the sources, double-click it again.

Content Location
User guide sources (Japanese, English) docs/ja, docs/en (chapter order in mkdocs.yml)
Top page, first steps, cheat sheet, recipes docs/index.md, docs/guide/, docs/recipes/, docs/en/index.md, docs/en/guide/
Figures and images docs/public/
Site configuration docs/.vitepress/

scripts/sync-manual.mjs copies the sources to chapter-number URLs (/manual/04, /en/manual/04) and places the files in examples/ for download (both are generated and not committed). Inside a sync folder such as Google Drive, node_modules links cannot be created and npm run dev / build fail; use docs_preview.bat or copy the project outside the sync folder.

Tests

python -m pip install -e ".[maiml]" pytest
pytest    # doesn't connect to eLabFTW

tests/live/ contains scripts that write to a real server; pytest doesn't run them. See 13. Testing and development.

License

Apache License 2.0 (LICENSE)

This library is an independent implementation of a helper library for the eLabFTW REST API. It doesn't include, modify, or redistribute eLabFTW's server-side source code. It's meant to be used with elabapi-python (MIT License), the Python client for the eLabFTW API.

In designing this library and its usage examples, we referred to NAIST's eLabFTW-related repository naist-eln/eln, but this library doesn't copy its code as-is. Note that the API/ directory of the NAIST repository contains a license file for the GNU Affero General Public License v3.0 (AGPL-3.0).


Copyright 2026 Japan Synchrotron Radiation Research Institute (JASRI) / Takahiro Matsumoto

Metadata

Release files for elabftw-toolkit 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for elabftw-toolkit 0.1.4
File Size Uploaded Provenance Actions
elabftw_toolkit-0.1.4.tar.gz 186.6 kB With provenance Details for elabftw_toolkit-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for elabftw-toolkit 0.1.4
File Interpreter ABI Platform Actions
elabftw_toolkit-0.1.4-py3-none-any.whl Python 3 none any Details for elabftw_toolkit-0.1.4-py3-none-any.whl

Total release size: 352.2 kB

Release files / elabftw_toolkit-0.1.4.tar.gz

Download URL elabftw_toolkit-0.1.4.tar.gz
Size 186.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f669cd6de280f89045d9f0be560ee42124099466007b00ca59d6e92df074b5d3
BLAKE2b-256 checksum
How to use checksums
bd5f569d4c32119468486907443ba2b202d1d5e79e3f2f1f51ac309f3e758081
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / elabftw_toolkit-0.1.4-py3-none-any.whl

Download URL elabftw_toolkit-0.1.4-py3-none-any.whl
Size 165.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae612ab4f9334e8e540bfd861c14348805d93b4d19d4b3a1ac18e8b097edfd43
BLAKE2b-256 checksum
How to use checksums
f66ab080c275ad891bfa86c7d16540c783ab6ee754b0ad35b18c4d8cf69a1883
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Security for elabftw-toolkit 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for elabftw_toolkit-0.1.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page