Skip to main content

M-Files gRPC API client for Python

The Python package mfiles-grpc for the M-Files gRPC API, with runnable examples: a quickstart and one program per task recipe. The guides on developer.m-files.com embed their code.

The package has two parts:

  • mfiles: the stubs generated from the M-Files protos, one module per service (from mfiles import IRPCSearch_pb2, IRPCSearch_pb2_grpc, structs_pb2).
  • mfiles_grpc: what the protos cannot express. MFilesClient opens the channel (TLS or not, an optional custom root certificate, the message size limits of M-Files' own client), adds the M-Files call metadata and cookies to every call, logs in and out (with a password, a token or through the browser), decodes errors into MFilesError and keeps the vault's metadata structure version. mfiles_grpc.values builds object IDs, typed values, search conditions and ACLs; mfiles_grpc.sso and mfiles_grpc.token_cache sign in through the browser.

The package is a preview: its helpers can still change between releases.

Install

From PyPI, the version for your server (see Versions):

pip install mfiles-grpc                  # add [keyring] to remember browser sign-ins

Or from this folder, which needs the protos (the proto folder of the API bundle, or proto/ here):

python -m venv .venv
.venv/bin/pip install -r requirements.txt        # Windows: .venv\Scripts\pip ...
.venv/bin/python generate.py [PROTO_DIR]
.venv/bin/pip install -e .

generate.py writes the stubs into src/mfiles/. Without PROTO_DIR it uses $MFILES_PROTO_DIR, proto/, ../../proto (the layout of the documentation download, where samples/ and proto/ are siblings) or the bundle built in the M-Files repository.

Python 3.10 or newer.

Configure

MFilesClient.from_env() and the examples read environment variables:

Variable Meaning
MFILES_ADDRESS host:port of the gRPC endpoint, e.g. myvault.cloudvault.m-files.com:443 or myserver:7766
MFILES_TLS true (default) or false for a server without TLS
MFILES_CA_CERT Optional: a PEM file of root certificates to trust, e.g. for a self-signed certificate
MFILES_VAULT The vault GUID, with braces
MFILES_USERNAME, MFILES_PASSWORD An M-Files user account
MFILES_AUTH browser to sign in through the browser with the vault's OAuth plugin, such as M-Files Login Service; then MFILES_VAULT is optional
MFILES_REMEMBER_SIGN_IN true to keep the refresh token of a browser sign-in in the operating system's credential store (needs keyring)
MFILES_TOKEN, MFILES_AUTH_PLUGIN, MFILES_AUTH_SCOPE Or a token from the vault's identity provider, and optionally the authentication plugin and its configuration scope

M-Files Cloud: port 443 with TLS. On-premises: the server's gRPC port, by default 7766; use MFILES_TLS=false only if the server has no certificate configured.

Examples

python examples/quickstart.py
python examples/recipes/search.py 1 30 10
Program What it shows Arguments (all optional)
quickstart.py Log in and list the 10 most recently modified documents
recipes/connect.py Server version, capabilities, log in, session info, keep-alive, log out
recipes/find_vault.py Find a vault's GUID by its name and open a session to it vault name (the first vault); MFILES_VAULT is not needed
recipes/login_service.py Sign in through M-Files Login Service in the browser --remember
recipes/vault_structure.py Object types, classes, property definitions; resolve an ID by alias class alias, property alias
recipes/search.py Documents of a class modified in the last N days, newest first class ID (1), days (30), limit (10)
recipes/read_object.py An object's latest version and its typed property values object ID (437), object type (0)
recipes/download_file.py Download a document's file document ID (437), folder (mfiles-grpc-samples in the temporary folder)
recipes/create_document.py Upload a file and create a document --keep
recipes/update_properties.py Change properties with an explicit version, and with check out / check in --keep
recipes/workflow_state.py Workflow states and allowed transitions; change the state workflow ID (107), initial state (137), target state (141), --keep
recipes/paging.py Go through a large result set page by page page size (100)
recipes/errors.py Handle "not found" and "access denied"

The programs are in examples/. The defaults suit the M-Files Sample Vault. Recipes that write create documents whose titles start with [docs-test] and delete them at the end unless you pass --keep.

A failed call raises mfiles_grpc.MFilesError, which carries the gRPC status (status), the message (message), the M-Files error code of the top-level error (hresult, hresult_hex, hresult_signed), the codes of the whole error stack (codes) and has(code) to test for a code anywhere in it.

Tests

python -m unittest discover -s tests      # unit tests; no server needed
python run_tests.py                        # the unit tests, then every example against a vault

run_tests.py uses the package from src/, reads ~/.mfiles-grpc-docs/test-config.json (section local), sets the variables above, runs the quickstart and every recipe as the configured user and fails if any of them fails (except recipes/login_service.py, which needs a person to sign in in the browser). If the section also has an admin account, it then destroys the deleted [docs-test] objects that the recipes left behind. See the docstring of run_tests.py for the file format.

Versions

There is one package version per M-Files Server release: 26.11.0 is for 26.11, 26.11.1 a revision of it. A version works with its server release and later ones; with an older server, methods that the server does not have fail with UNIMPLEMENTED.

License

MIT; see LICENSE.

Metadata

Release files for mfiles-grpc 26.11.0

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

Source distribution (sdist)

Source distribution for mfiles-grpc 26.11.0
File Size Uploaded Provenance Actions
mfiles_grpc-26.11.0.tar.gz 657.9 kB With provenance Details for mfiles_grpc-26.11.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mfiles-grpc 26.11.0
File Interpreter ABI Platform Actions
mfiles_grpc-26.11.0-py3-none-any.whl Python 3 none any Details for mfiles_grpc-26.11.0-py3-none-any.whl

Total release size: 1.4 MB

Release files / mfiles_grpc-26.11.0.tar.gz

Download URL mfiles_grpc-26.11.0.tar.gz
Size 657.9 kB
Tags Source
SHA-256 checksum
How to use checksums
64b33521eb052fe851a26ef254e6880745227fbf18daf04ea544cb0f50a56749
BLAKE2b-256 checksum
How to use checksums
38b833676c3486f634799a0c962dc6c6347b29de1a92ba9cb0efa044f06bc42e
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 Nov 5, 2026.

Transparency log

Release files / mfiles_grpc-26.11.0-py3-none-any.whl

Download URL mfiles_grpc-26.11.0-py3-none-any.whl
Size 786.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4cc58de0a6825159e4832aab004dde459a7b172e768ddd70a73a27a02f38fb88
BLAKE2b-256 checksum
How to use checksums
2d31a17da3d5dd2150d53246ef8380f89e3fdf68b2b009e8b0b700c2cfd7b1ed
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 Nov 5, 2026.

Transparency log

Security for mfiles-grpc 26.11.0

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 mfiles_grpc-26.11.0.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 Nov 5, 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