Skip to main content

routeros-lsp

A Language Server Protocol server for MikroTik RouterOS scripts (.rsc files).

It gives editors and AI coding agents immediate feedback while they write RouterOS scripts: syntax errors, unknown menus, commands and parameters, variable scope mistakes, and completion and hover from the RouterOS command list. It follows the RouterOS scripting documentation, and where the documentation is silent or a real router behaves differently, the behaviour was measured on a router and written down in docs/ambiguities.md instead of guessed.

PyPI Python CI License: MIT

What it reports

Area Examples
Syntax Unterminated strings, bad escapes, unbalanced brackets, two values with no space between them, a # comment after a command (RouterOS reads it as an argument and rejects the line), a line break inside ( ), whitespace before =.
Variables :set of a variable that is not declared in scope, a local used on a later line of an imported file (where it is empty), undeclared variables, invalid names.
Menus and commands An unknown menu, command or parameter with a "did you mean", an ambiguous abbreviation, a parameter given twice, too many unnamed arguments, a missing required parameter. The menu path is tracked as RouterOS does, so relative commands after /ip address are checked in that menu.

Hover and completion use the same command list: menus and commands, parameters (required ones first), values after name=, and the variables in scope after $. There is also a symbol outline and folding. docs/features.md has the details and the limits; docs/rules.md lists every rule with its default severity.

A finding is labelled when it rests on RouterOS behaviour that the documentation does not describe, so a quirk of one version is never presented as the language specification.

Install and use

Python 3.10 or newer, no other dependencies:

pipx install routeros-lsp      # or: uv tool install routeros-lsp
routeros-lsp --version

To try the unreleased master, install straight from the repository:

pipx install git+https://github.com/wiresage/routeros-lsp.git

The server speaks LSP over stdio:

routeros-lsp --stdio

uvx routeros-lsp --stdio runs it without installing anything.

Claude Code

plugin/ is a Claude Code plugin that starts the server for .rsc files (language id routeros). It expects the routeros-lsp command on your PATH. Settings go into its .lsp.json; see docs/configuration.md.

Other editors

Start routeros-lsp --stdio for the language id routeros from any LSP client.

Check files from the command line

The same analysis runs without an editor, for a pre-commit hook, a CI job or a script an AI agent just wrote:

routeros-lsp check backup.rsc scripts/        # files and directories (every .rsc below them)
routeros-lsp check --strict --format json export.rsc
cat export.rsc | routeros-lsp check -         # standard input

Findings are printed as path:line:column: severity: message [rule], or as a JSON array with --format json; a summary goes to stderr, so stdout can be piped. The exit status is 0 when there is nothing to fix, 1 when errors were found (with --strict warnings count too) and 2 when a file cannot be read or an option is wrong. The settings of the editor integration are options: --scope, --schema, --severity RULE=LEVEL and --context-variable NAME; see routeros-lsp check --help.

The command list

Menus, commands and parameters come from a database generated from a RouterOS 7.21.4 CHR with /console/inspect (src/routeros_lsp/data/routeros-7.21.4.json.gz). A CHR has no wireless, LTE or switch-chip packages and some parameters exist only on some hardware, so unknown-name findings are warnings by default. To cover your own hardware, generate the database from your router (nothing is executed or changed on it) and point the schema setting at it:

pip install paramiko
ROUTEROS_PASSWORD=... python tools/gen_schema.py --host 192.0.2.1 --user admin --out my-router.json.gz

Develop

python -m venv .venv && . .venv/bin/activate     # on Windows: .venv/Scripts/activate
pip install -e ".[dev]"
ruff check . && mypy && pytest

The tests need no router. Releases are cut by the pipeline in docs/releasing.md. See CONTRIBUTING.md, AGENTS.md and docs/architecture.md.

How the language was pinned down

  • docs/grammar.md: the grammar derived from the documentation, each rule tagged as documented, shown by an example, observed on a device, or open.
  • docs/ambiguities.md: every gap and conflict, with evidence from RouterOS 7.21.4 and the default used.
  • research/: the probes that produced that evidence. RouterOS can check a script without running it (/import file.rsc verbose=yes dry-run), which is the test oracle for this project; tests/conformance/ replays more than 800 recorded answers.

License

MIT

Metadata

Release files for routeros-lsp 0.2.1

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

Source distribution (sdist)

Source distribution for routeros-lsp 0.2.1
File Size Uploaded
routeros_lsp-0.2.1.tar.gz 207.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for routeros-lsp 0.2.1
File Interpreter ABI Platform
routeros_lsp-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 398.2 kB

Release files / routeros_lsp-0.2.1.tar.gz

Download URL routeros_lsp-0.2.1.tar.gz
Size 207.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4fed6526fcb29b9250359763a3256112bc1594d4170957f6603f8eec1bd072d4
BLAKE2b-256 checksum
How to use checksums
4b398cebd171e28ffc28840e51c525963138e49774c2b21cad3c83aba45aac44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 15, 2026.

Transparency log

Release files / routeros_lsp-0.2.1-py3-none-any.whl

Download URL routeros_lsp-0.2.1-py3-none-any.whl
Size 190.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31593c42dbf855ca18cad1d54d8b933550a60242e6ced0001667a4b43c136e3b
BLAKE2b-256 checksum
How to use checksums
af3c3b1c2e3f9a600a3ab558a3bb58c7efbbf3cb1868813ed79c3f73bdaba8b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

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