Migrating the MikroTik MCP server to mcp 2.0

1 hour ago

This pull request moves the MikroTik server onto version two of the MCP library. The earlier fix capped the library below two as a stopgap, and this one does the real migration. The server class was renamed from FastMCP to MCPServer, and the library now needs Python 3.10 or newer, so this is a breaking change for anyone on older Python.

Ask about this presentation

Chapters

  1. 0:00The change
  2. 0:24What mcp 2.0 changed
  3. 0:53The version bound
  4. 1:14Evidence
  5. 1:41What to do
Show transcript
  1. This pull request moves the MikroTik server onto version two of the MCP library. The earlier fix capped the library below two as a stopgap, and this one does the real migration. The server class was renamed from FastMCP to MCPServer, and the library now needs Python 3.10 or newer, so this is a breaking change for anyone on older Python.

    Slide text
    PULL REQUEST 102

    The server now runs on mcp 2.0, and every tool still behaves the same.

    FastMCP became MCPServer. Python 3.10 or newer is required.
  2. First, the import. The class and its module moved, so the app, the connector and all nineteen scope modules changed one line each. Second, the tool annotation fields became snake case. The old camel case names survive as serialization aliases, so what clients receive over the wire is unchanged, and that matters because read only mode depends on those annotations. Third, the settings object is gone, so host and port are now passed straight to run, and standard input and output takes none.

    Slide text
    API CHANGES

    The API renames, handled in the app.

    from mcp.server.fastmcp import FastMCP
    from mcp.server.mcpserver import MCPServer
    ToolAnnotations(readOnlyHint=True)
    ToolAnnotations(read_only_hint=True)
  3. The new range requires version two and stops short of three. The author kept the upper bound on purpose, because the earlier incident showed that an open ended range lets a breaking release reach users silently. A version bound test was rewritten to enforce this, and to fail if any import from the old fastmcp module comes back.

    Slide text
    DEPENDENCY

    The upper bound stays.

    mcp>=1.10.0,<2.0.0
    mcp>=2.0.0,<3.0.0
    An unbounded range let a breaking major reach users once already.
  4. The author ran fifteen live checks against a real RouterOS device, over standard input and output and over streamable HTTP. They covered reads, an IPv6 create and delete round trip, and a byte exact file transfer. The DNS rebinding protection from the earlier host allowlist work still rejects a foreign host header. The unit tests pass too, and the Docker image builds and serves live data on the new version.

    Slide text
    EVIDENCE

    Checked live against a RouterOS device.

    15 of 15live checks passed on RouterOS 7.21.4
    421still returned for a foreign Host header
    93unit tests pass
  5. The one review comment asked for two explanatory comments in the app module to be removed, and the current file no longer has them. The real limit is the Python floor. Anyone on three eight or three nine stays on the previous release. Everyone else gets the same tools, now on a supported version of the library.

    Slide text
    FOR REVIEWERS

    Upgrade if you run Python 3.10 or newer.

    Older Python can no longer install this server.

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