elabftw-toolkit
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 ofELABFTW_API_KEY. .envfiles aren't loaded automatically. If you use one, callfrom 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 |
elabftw-maiml check <folders…> |
Check MaiML files and the links between them (needs [maiml]) |
10. MaiML export |
elabftw-maiml graph <folders…> |
Draw the links between MaiML files in several places as a Mermaid diagram | 10. MaiML export |
elabftw-benten check <folder> |
Check BENTEN metadata (metadata.all.yml) against the schema (needs [benten]) |
16. MCP server |
Every command lists its arguments with --help. If a command is not found (the folder where pip puts commands is not on your PATH), python -m elabftw_toolkit.maiml, python -m elabftw_toolkit.benten_schema and python -m elabftw_toolkit.mcp_server work the same way.
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 |
- The server only reads by default. Write tools work only with
ELABFTW_ALLOW_WRITE=1(previews withdry_run=truealways work;ELABFTW_READ_ONLY=1keeps it read-only). upload_filereads only files insideELABFTW_UPLOAD_DIR;load_schemaandschema_pathonly insideELABFTW_SCHEMA_DIR(and the folders ofELABFTW_SCHEMA/ELABFTW_SM_SCHEMA).- Write tools other than
lock_entry/unlock_entryreturn only "old value → new value" withdry_run=true, and record the reason as a comment on the entry withreason="…". - Tool calls are written to an audit log (
ELABFTW_MCP_AUDIT; by default bodies and similar are kept only as length + hash). When eLabFTW cannot be reached, tools return an error instead of "no results". - 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.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| elabftw_toolkit-0.1.7.tar.gz | 193.4 kB | With provenance | Details for elabftw_toolkit-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| elabftw_toolkit-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for elabftw_toolkit-0.1.7-py3-none-any.whl |
Total release size: 363.5 kB
Release files / elabftw_toolkit-0.1.7.tar.gz
| Download URL | elabftw_toolkit-0.1.7.tar.gz |
|---|---|
| Size | 193.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f56c20daa2d9577c8792925da0b183826a9c667d77dbe8d17a74776c4435af88
|
|
BLAKE2b-256 checksum How to use checksums |
2d1d2551f118f6cba9c4a579a1c0354a33d4a5422282e259584c039055227d35
|
| 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 3, 2026.
Transparency logRelease files / elabftw_toolkit-0.1.7-py3-none-any.whl
| Download URL | elabftw_toolkit-0.1.7-py3-none-any.whl |
|---|---|
| Size | 170.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd071e5d3b3b7c88d40f8e0a65fe9f98ac576c4467cd5096b4397f62eca3e5bc
|
|
BLAKE2b-256 checksum How to use checksums |
3c51db2be24d8a85d0692989a17941f2a0e2b261f20475d07bc98047cfedecba
|
| 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 3, 2026.
Transparency logSecurity for elabftw-toolkit 0.1.7
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.
Attestation for elabftw_toolkit-0.1.7.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 3, 2026.
Transparency logA 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.