Skip to main content

bankstatementparser-lsp logo

bankstatementparser-lsp

Language server that lints MT940 bank-statement files as you type, flagging missing tags and malformed balance, statement and information lines in any LSP editor.

Build Registry Docs OpenSSF Scorecard License: Apache-2.0 OR MIT Python 3.10+

A terminal printing bankstatementparser-lsp 0.0.37, then the 01_lsp_helpers.py and 04_server_publish.py examples linting clean and broken MT940 statements and publishing their diagnostics


Contents

Getting started

The bankstatementparser-lsp ecosystem

Library reference

Operational


Install

As a Python library

pip install bankstatementparser-lsp

That installs the bankstatementparser-lsp command, bankstatementparser >= 0.0.36 and pygls.

Channel Command Notes
PyPI pip install bankstatementparser-lsp The server and the importable engine
Source git clone https://github.com/sebastienrousseau/bankstatementparser-lsp && cd bankstatementparser-lsp && poetry install For development
Docker (GHCR) docker pull ghcr.io/sebastienrousseau/bankstatementparser-lsp:latest Multi-arch (linux/amd64, linux/arm64); runs bankstatementparser-lsp over stdio

Verify the installation:

python -c "import bankstatementparser_lsp; print('bankstatementparser-lsp', bankstatementparser_lsp.__version__)"
# -> bankstatementparser-lsp 0.0.37

An isolated virtual environment keeps the server's dependencies apart:

python -m venv venv
source venv/bin/activate        # macOS/Linux
venv\Scripts\activate           # Windows
python -m pip install -U bankstatementparser-lsp

Packaging status

Packaging status

Repology lists every repository that packages bankstatementparser-lsp. PyPI and GHCR are the channels this project publishes to itself.


Requirements

  • Python 3.10 or later. CI tests CPython 3.10, 3.11, 3.12, 3.13 and 3.14 on Linux, macOS and Windows; docs/POLICIES.md says when the floor moves.
  • bankstatementparser 0.0.36 or later, whose MT940 tag patterns the engine follows.
  • pygls 2.1 or later on 2.x, which brings lsprotocol.
  • An LSP client (Neovim, VS Code, Helix, Emacs, or any client that spawns a stdio server). The Docker image needs only a container runtime.

Quick Start

-- Neovim: map the MT940 extensions to a filetype and start the server.
vim.filetype.add({ extension = { mt940 = "mt940", sta = "mt940" } })

vim.lsp.config["bankstatementparser"] = {
  cmd = { "bankstatementparser-lsp" },
  filetypes = { "mt940" },
  root_markers = { ".git" },
}
vim.lsp.enable("bankstatementparser")

Open any MT940 statement (.mt940 / .sta) and diagnostics appear as you type. The bankstatementparser-lsp command speaks LSP over stdin and stdout, so it is meant to be launched by your editor's LSP client, not used interactively. VS Code, Helix and other clients are covered in Editor wiring.


The bankstatementparser-lsp ecosystem

bankstatementparser-lsp is the editor-facing member of the bankstatementparser suite, whose packages ship one version together. The full table is in The suite.

Component Purpose Use case
bankstatementparser The parser core: CAMT, pain.001, CSV, OFX, QFX, MT940 and PDF statements Parsing statements from Python or the CLI
bankstatementparser-lsp This server: live MT940 diagnostics Editing MT940 files
bankstatementparser-mcp Model Context Protocol server over the parser core AI agents reading statements
Loaders, writers and transport BAI2, MT942, CFONB, CAMT.054, SEPA and BACS loaders; XLSX, QIF, OFX and SWIFT writers; EBICS transport Formats beyond the core, and retrieval over EBICS
flowchart LR
    A["Editor (VS Code / Neovim / ...)"] -->|LSP over stdio| B["bankstatementparser-lsp"]
    B -->|diagnostics_for_mt940| C["diagnostic engine (MT940 tag patterns)"]
    C -->|Diagnostic objects| B
    B -->|publishDiagnostics| A

Capabilities at a glance

Area Capability Status
Diagnostics missing-tag, malformed-balance, malformed-statement-line, orphan-information-line Shipped
LSP methods textDocument/didOpen and textDocument/didChange, answered with textDocument/publishDiagnostics Shipped
Engine diagnostics_for_mt940, Diagnostic, Severity: pure Python, no LSP dependency Shipped
Input handling A leading UTF-8 BOM and CRLF line endings lint the same as plain LF text Shipped
Editors Neovim and generic stdio clients; a VS Code client scaffold in editors/vscode/ Shipped
Distribution PyPI wheel and sdist, multi-arch GHCR image Shipped
Outline, hover, code actions textDocument/documentSymbol, textDocument/hover and per-diagnostic code actions; see the roadmap Planned

Ecosystem comparison

The choice is between editor diagnostics, the parser itself, and the agent-facing server. Every cell comes from the projects' own READMEs.

Project Format Interface What it gives you
bankstatementparser-lsp MT940 LSP (stdio) Live diagnostics while editing
bankstatementparser CAMT, pain.001, CSV, OFX, QFX, MT940, PDF Python library and CLI Parsed statements
bankstatementparser-mcp CAMT.053, pain.001, MT940, OFX, QFX, CSV MCP tools Detection, parsing, validation for agents

See docs/COMPARISON.md for the evidence and complete matrix.


Benchmarks

benches/bench_diagnostics.py times one diagnostics_for_mt940 call on a whole document, which is what the editor waits for on every keystroke. Valid and malformed documents cost the same, and every size measured stays far under one frame (16 ms).

Scenario Result Environment
Valid statement, 100 entries (6.2 KiB) 0.12 ms Apple M1 Pro, macOS 27.2.1, CPython 3.12.16
Valid statement, 500 entries (32 KiB) 0.56 ms Apple M1 Pro, macOS 27.2.1, CPython 3.12.16
Malformed statement, 500 entries (32 KiB) 0.56 ms Apple M1 Pro, macOS 27.2.1, CPython 3.12.16

See docs/BENCHMARKS.md for methodology and full results.


Features

For MT940 bank-statement documents (one statement of SWIFT-style :tag: lines), bankstatementparser-lsp publishes diagnostics:

Rule code Severity Behaviour
missing-tag error A mandatory tag (:20:, :25:, :28C:, :60F:, :62F:) is absent
malformed-balance error A :60F: / :62F: balance line does not match C/D + YYMMDD + 3-letter currency + amount
malformed-statement-line error A :61: statement line does not match YYMMDD + C/D + amount
orphan-information-line warning An :86: information line has no preceding :61: statement line

Diagnostics are republished on textDocument/didOpen and textDocument/didChange, so the editor stays in sync on every keystroke. An empty or whitespace-only document produces no diagnostics.

The rules live in a pure, importable engine (diagnostics_for_mt940, returning Diagnostic objects with a Severity) in bankstatementparser_lsp.diagnostics; bankstatementparser_lsp.server is thin pygls glue that maps those objects to lsprotocol types and publishes them.


Configuration

The server has no configuration file, command-line options or environment variables: bankstatementparser-lsp takes no arguments and always speaks LSP over stdio. Everything you configure lives in the editor: the command, the mt940 filetype for .mt940 / .sta files, and the root markers. The VS Code scaffold exposes one setting, bankstatementparser.serverCommand (default bankstatementparser-lsp). Because the command takes no arguments, a shell has nothing to tab-complete.


Examples

Because the diagnostic engine is pure, you can call it directly, with no editor or server process. This is exactly what the server runs on each edit:

from bankstatementparser_lsp.diagnostics import diagnostics_for_mt940

# A clean MT940 statement produces no diagnostics.
clean = (
    ":20:STARTUMS\n"
    ":25:1234567890\n"
    ":28C:00001/001\n"
    ":60F:C230101EUR1000,00\n"
    ":61:2301020102C500,00NTRFNONREF//abc\n"
    ":86:Salary payment\n"
    ":62F:C230102EUR1500,00"
)
assert diagnostics_for_mt940(clean) == []

# Missing mandatory tags surface as errors.
diagnostics = diagnostics_for_mt940(":20:ONLY\n:61:2301020102C5,00NTRF")
print(len(diagnostics), "issue(s)")
# -> e.g. "4 issue(s)"

# Each diagnostic carries a 0-based range, a severity, and a rule code.
for d in diagnostics:
    print(d.line, d.code, d.message)
# -> 0 missing-tag Missing mandatory MT940 tag: :25:
#    ...

Each Diagnostic exposes line, col_start, col_end, severity (a Severity enum matching the LSP numeric scale), message, and a stable code, which the server maps to lsprotocol.Diagnostic before publishing.

examples/ holds four runnable scripts, each run in CI:

Example Demonstrates
01_lsp_helpers.py The engine on clean, incomplete and malformed statements
02_severity_filtering.py Grouping diagnostics by severity
03_lsp_conversion.py The lsprotocol conversion the server performs
04_server_publish.py The server's lint-and-publish path, driven by a fake LanguageServer so it runs without an editor

When not to use bankstatementparser-lsp

  • You're not editing MT940 statements. The server targets the SWIFT MT940 tag-and-line format (.mt940 / .sta); for CAMT XML or other formats use a format-appropriate language server.
  • You need full parsing, not editor diagnostics. Use the core bankstatementparser library to parse statements into structured records.
  • You need balance arithmetic checked. The rules check structure, not that the closing balance equals the opening balance plus the movements; that is on the roadmap.
  • You need MT942 or other SWIFT messages. Only MT940 is linted.

Development

git clone https://github.com/sebastienrousseau/bankstatementparser-lsp.git
cd bankstatementparser-lsp
mise install
poetry install
make check

make check runs the local gates: ruff and black, mypy --strict, the complexity baseline (scripts/check_complexity.py), Bandit, pytest with a 100% line + branch coverage floor, interrogate at 100% docstring coverage, and the examples. Other targets: make fuzz (Atheris, 60 s, Linux x86_64 with Python 3.12+), make docs (the MkDocs manual, --strict) and make demo (re-renders the GIF above with VHS from .github/demo.tape). CI adds the OS by Python matrix, the Docker build, CodeQL, pip-audit on the locked requirements and the Docs Lint gates. The suite includes documentation and example regression tests (tests/test_docs_accuracy.py, tests/test_regression_docs.py, tests/test_regression_examples.py) that execute every documented snippet and every examples/*.py script.

Current state (v0.0.37): 100% line + branch coverage against a 100% enforced floor, mypy --strict clean, interrogate 100% docstring coverage. CONTRIBUTING.md covers branches, commit signing and sign-off.


Security

  • No filesystem writes. The server reads from the editor's in-memory document buffer; no scratch files, no temp directories.
  • MT940 scanning is a pure-re line scanner over text from the editor: no eval, no shelling out, no XML, no network.
  • Lint findings are returned as lsprotocol.Diagnostic objects with no stack traces, so the editor never sees an internal path or exception message.
  • Fuzzing. fuzz/fuzz_diagnostics.py drives the engine and its lsprotocol conversion with Atheris in CI and fails on any exception or any diagnostic outside the document.
  • Supply chain. Dependencies are locked in poetry.lock, CI and the container install hash-pinned exports of it, and pip-audit, Bandit and CodeQL run on every change. Releases publish to PyPI through OIDC trusted publishing and carry cosign signatures, SLSA provenance and SBOMs; every workflow action is pinned by commit SHA except the SLSA generator, which must be referenced by tag.

Report vulnerabilities according to SECURITY.md.


Documentation


Stability guarantees

  • Versioning. Releases stay on the 0.0.x line and step by exactly 0.0.1, in lockstep with the rest of the bankstatementparser suite. Under SemVer a 0.0.x release may break anything; this project names each break in the CHANGELOG instead.
  • The breaking axis is the diagnostics: rule codes, their severities, and the ranges they cover. Renaming or removing a code, changing its severity, or flagging text a rule did not flag before is a breaking change and is called out in the CHANGELOG, even when no Python signature moves. A new rule is an addition.
  • Output stability. The engine is deterministic: the same document gives the same diagnostics in the same order.
  • Python API. diagnostics_for_mt940, Diagnostic and Severity (exported from bankstatementparser_lsp) keep their names and fields; names starting with _ are internal.
  • Minimum toolchain. Python 3.10 is the floor; it moves only in a release, for the whole suite at once, with the reason in the CHANGELOG (docs/POLICIES.md).

License

Dual-licensed under Apache License, Version 2.0 or MIT, at your option (SPDX-License-Identifier: Apache-2.0 OR MIT). Built on pygls by the Open Law Library, on lsprotocol by Microsoft, and on the core bankstatementparser library. Any contribution submitted for inclusion in the work shall be dual-licensed as above, without additional terms or conditions.

Metadata

Release files for bankstatementparser-lsp 0.0.37

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

Source distribution (sdist)

Source distribution for bankstatementparser-lsp 0.0.37
File Size Uploaded Provenance Actions
bankstatementparser_lsp-0.0.37.tar.gz 21.7 kB With provenance Details for bankstatementparser_lsp-0.0.37.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bankstatementparser-lsp 0.0.37
File Interpreter ABI Platform Actions
bankstatementparser_lsp-0.0.37-py3-none-any.whl Python 3 none any Details for bankstatementparser_lsp-0.0.37-py3-none-any.whl

Total release size: 39.7 kB

Release files / bankstatementparser_lsp-0.0.37.tar.gz

Download URL bankstatementparser_lsp-0.0.37.tar.gz
Size 21.7 kB
Tags Source
SHA-256 checksum
How to use checksums
74680150a074479e805e1c7ecfa4f02c81e7519a8e1b1af82dcb914952e70ac5
BLAKE2b-256 checksum
How to use checksums
33098820dc42d1794fd44423ef37925f26e8df52ecc13294c760df07f29bbf0f
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 29, 2026.

Transparency log

Release files / bankstatementparser_lsp-0.0.37-py3-none-any.whl

Download URL bankstatementparser_lsp-0.0.37-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
29196150a54b54659391d4eefd97adde3ad6b7d38608ad2b617c7d13af09fefa
BLAKE2b-256 checksum
How to use checksums
09d2a29cfa4e70397a2215a2e4462f08e45b34a084b7092a4adbb5acdaabfe84
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 29, 2026.

Transparency log

Security for bankstatementparser-lsp 0.0.37

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 bankstatementparser_lsp-0.0.37.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 29, 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