Read-only mode for MikroTik MCP: tools that can look but not change

1 hour ago

This pull request adds a read-only mode to the MikroTik MCP server. Set one environment variable, or pass one flag, and the assistant only gets the tools that look at the router. Anything that adds, changes or removes something never gets registered, so the model can't even ask for it.

Ask about this presentation

Chapters

  1. 0:00Read-only mode
  2. 0:19How it works
  3. 0:43Exports write files
  4. 1:15What is still open
Show transcript
  1. This pull request adds a read-only mode to the MikroTik MCP server. Set one environment variable, or pass one flag, and the assistant only gets the tools that look at the router. Anything that adds, changes or removes something never gets registered, so the model can't even ask for it.

    Slide text
    MikroTik MCP

    One switch turns the server read-only

    MIKROTIK_READ_ONLY=true  or  --read-only
  2. The filter sits in the server wrapper, which the author moved into its own file after the first review. When a tool registers itself, the wrapper checks its annotation. If read-only mode is on and the tool isn't marked as a read, the decorator hands the function back untouched, and it never reaches the tool list. That makes the annotation a safety control, so every tool has to be marked honestly.

    Slide text
    The filter

    Tools without the read annotation are never registered

    if config.mikrotik_config.read_only and not (
        annotations and annotations.read_only_hint
    ):
        return lambda fn: fn
  3. The first version marked only two exports as writes. A reviewer then confirmed on a lab router that an export really does write a file into the device's file store. So the config export and the log export became writes. The reviewer also spotted that the DNS export and the user export run the same command and were still marked as reads. Both were fixed, and the regression test now scans the command strings for export, print to file, and backup save, instead of listing tool names by hand.

    Slide text
    Review feedback

    Exports create files, so they stopped counting as reads

    create_export /export file=
    export_logs file on the router
    export_dns_config /ip dns export file=
    export_user_config /user export file=
  4. The docs say it plainly: this mode filters what the assistant is offered, and a restricted RouterOS account is what actually enforces it. Please review with that in mind, and look at the file download tool, which stays a read because it only fetches a file that already exists. The author tested it against a real router. Asked to rename an interface, the assistant explained it was in read-only mode and handed back the command to run by hand. The full suite of about 190 unit tests passes.

    Slide text
    Before you rely on it

    The router account is the real lock

    Read-only mode filters tools. A RouterOS user with read-only rights enforces it.
    download_file stays a read
    Smoke tested on a real router, twice

What happened in AI today, in your inbox

One short email each evening. Read it and you’re caught up.

Built with ❤️ in New York