### Run the MikroMCP setup wizard Source: https://github.com/alikarami/mikromcp/wiki/Getting-Started Starts the interactive setup wizard that generates config files and tests the router connection. It writes `~/.mikromcp/routers.yaml` and `~/.mikromcp/.env`, and optionally registers with Claude Desktop. ```bash mikromcp init ``` -------------------------------- ### Quick start commands (npm install) Source: https://github.com/alikarami/mikromcp/wiki/Running Use these commands after installing MikroMCP via npm. `mikromcp init` runs a first-time setup wizard, `mikromcp doctor` verifies router connectivity and config, `mikromcp serve` starts the MCP server in stdio mode, and `mikromcp update` updates to the latest version. ```bash mikromcp init # first-time setup wizard mikromcp doctor # verify router connectivity and config mikromcp serve # start the MCP server (stdio mode) mikromcp update # update to the latest version ``` -------------------------------- ### Prompt: List all interfaces on my router Source: https://github.com/alikarami/mikromcp/wiki/Getting-Started Example prompt to paste into your AI assistant to verify the MikroMCP connection. Expect the assistant to call MikroMCP tools and return real data from your router. ```text List all interfaces on my router ``` -------------------------------- ### Clone and build MikroMCP from source Source: https://github.com/alikarami/mikromcp/wiki/Getting-Started Clones the repository, installs dependencies, and builds the project. After this, replace `mikromcp` with `node /path/to/MikroMCP/dist/main.js` in all commands. ```bash git clone https://github.com/AliKarami/MikroMCP.git cd MikroMCP npm install npm run build ``` -------------------------------- ### Install MikroMCP globally via npm Source: https://github.com/alikarami/mikromcp/wiki/Getting-Started Recommended installation method. After running this command, the `mikromcp` command is available globally. ```bash npm install -g mikromcp ``` -------------------------------- ### Test prompts for MikroMCP Source: https://github.com/alikarami/mikromcp/blob/main/docs/wiki/Getting-Started.md Example prompts to paste into an AI assistant to verify MikroMCP connectivity. Each should trigger tool calls that return real router data, visible in the assistant's tool-use panel. ```text List all interfaces on my router ``` ```text Show me the firewall rules on core-01 ``` ```text What's the CPU and memory usage right now? ``` ```text Are there any active DHCP leases? ``` ```text Ping 8.8.8.8 from core-01 and tell me the round-trip time ``` -------------------------------- ### Build and start MCP server (backward compat) Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-19-v1.0-distribution-onboarding.md Builds the project and starts the MCP server to ensure backward compatibility. ```bash npm run build && node dist/main.js ``` -------------------------------- ### Pull MikroMCP Docker image Source: https://github.com/alikarami/mikromcp/wiki/Getting-Started Pulls the latest MikroMCP Docker image from GitHub Container Registry. See the 'Connecting to AI Assistants' page for a full Docker run example. ```bash docker pull ghcr.io/alikarami/mikromcp:latest ``` -------------------------------- ### Prompt: Check CPU and memory usage Source: https://github.com/alikarami/mikromcp/wiki/Getting-Started Example prompt to paste into your AI assistant to verify the MikroMCP connection. Expect the assistant to call MikroMCP tools and return real data from your router. ```text What's the CPU and memory usage right now? ``` -------------------------------- ### Build the docs site Source: https://github.com/alikarami/mikromcp/blob/main/docs-site/DEPLOY.md Run from the docs-site directory. Installs dependencies and builds the static Starlight site, outputting to docs-site/dist/ and generating a Pagefind search index. npm ci must install the platform-specific Pagefind binary; if the build fails with 'Failed to install either of [pagefind_extended, pagefind]', delete node_modules and package-lock.json and run npm install once with network access. ```bash cd docs-site npm ci npm run build ``` -------------------------------- ### Manual router configuration in routers.yaml Source: https://github.com/alikarami/mikromcp/wiki/Getting-Started Alternative to the wizard. Create `~/.mikromcp/routers.yaml` (or any path pointed to by `MIKROMCP_CONFIG_PATH`) with router details, TLS settings, and credentials sourced from environment variables. ```yaml routers: core-01: host: "10.0.0.1" port: 443 tls: enabled: true rejectUnauthorized: false # set true once you have a valid cert credentials: source: "env" envPrefix: "ROUTER_CORE01" # env vars: ROUTER_CORE01_USER / ROUTER_CORE01_PASS tags: ["core"] rosVersion: "7.14" ``` -------------------------------- ### Install and verify the build Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-31-landing-page.md Runs npm install and the Astro build, expecting completion and the generated index.html containing the heading. ```bash cd site && npm install && npm run build ``` -------------------------------- ### Run standalone binary (no Node.js) Source: https://github.com/alikarami/mikromcp/wiki/Getting-Started For platforms without Node.js. Download the binary from the latest GitHub release, make it executable, and run it in place of the `mikromcp` command. ```bash chmod +x mikromcp-linux-x64 ./mikromcp-linux-x64 doctor ``` -------------------------------- ### Commit identities.example.yaml Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-14-v0.7-identity-auth-audit.md Stage and commit the new example configuration file. ```bash git add config/identities.example.yaml git commit -m "docs(config): add identities.example.yaml with token generation instructions" ``` -------------------------------- ### Prompt: Ping 8.8.8.8 from core-01 Source: https://github.com/alikarami/mikromcp/wiki/Getting-Started Example prompt to paste into your AI assistant to verify the MikroMCP connection. Expect the assistant to call MikroMCP tools and return real data from your router. ```text Ping 8.8.8.8 from core-01 and tell me the round-trip time ``` -------------------------------- ### Add HTTP/SSE transport subsection with bash example Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-04-24-v0.2.md Add this markdown subsection after the environment variables table. It explains how to set `MIKROMCP_TRANSPORT=http` to run MikroMCP as an HTTP server, listening on `MIKROMCP_PORT` (default 3000) and accepting MCP JSON-RPC at `POST /mcp` and SSE at `GET /mcp`. The bash command shows how to start the server with the required environment variables. ```markdown #### HTTP/SSE transport Set `MIKROMCP_TRANSPORT=http` to expose MikroMCP as an HTTP server instead of stdio. The server listens on `MIKROMCP_PORT` (default `3000`) and accepts MCP JSON-RPC at `POST /mcp`. Clients that support Server-Sent Events can also use `GET /mcp` for streaming. ```bash MIKROMCP_TRANSPORT=http MIKROMCP_PORT=3000 \ MIKROMCP_CONFIG_PATH=config/routers.yaml \ ROUTER_CORE01_USER=mcp-api ROUTER_CORE01_PASS=secret \ npm start ``` To connect Claude Desktop to an HTTP transport, point it at the running server using an HTTP MCP client rather than the stdio command form. Check your MCP client documentation for its HTTP transport configuration. ``` ```bash MIKROMCP_TRANSPORT=http MIKROMCP_PORT=3000 \ MIKROMCP_CONFIG_PATH=config/routers.yaml \ ROUTER_CORE01_USER=mcp-api ROUTER_CORE01_PASS=secret \ npm start ``` -------------------------------- ### Add maintenanceWindows example to routers.example.yaml Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-17-v0.8-change-safety-rollback.md Adds a commented example of maintenanceWindows to the core-01 block, showing days, startTime, endTime, and timezone. ```yaml # maintenanceWindows: # Destructive tools blocked outside these windows # - days: ["Sat", "Sun"] # Days when maintenance is permitted # startTime: "02:00" # 24-hour HH:MM in the specified timezone # endTime: "06:00" # timezone: "Europe/Helsinki" ``` -------------------------------- ### Set up Docker Compose for MikroMCP Source: https://github.com/alikarami/mikromcp/wiki/Connecting-to-AI-Assistants Copies example config files and starts the service with Docker Compose. Requires editing routers.yaml and creating a .env with the confirmation secret and router credentials. ```bash cp docker-compose.example.yml docker-compose.yml cp config/routers.example.yaml config/routers.yaml cp config/identities.example.yaml config/identities.yaml # Edit config/routers.yaml and create a .env with MIKROMCP_CONFIRMATION_SECRET and router credentials docker compose up -d ``` -------------------------------- ### Install and verify Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-06-02-docs-site.md Run npm install and astro build directly (not npm run build) to bypass the not-yet-written prebuild hook. Expected: build completes and docs-site/dist/index.html exists. ```bash cd docs-site && npm install && npx astro build ``` -------------------------------- ### Commit deployment guide Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-06-02-docs-site.md Commits the deployment guide for nginx and Cloudflare to the docs-site repository. ```bash git add docs-site/DEPLOY.md git commit -m "docs(docs-site): deployment guide for nginx + Cloudflare" ``` -------------------------------- ### Prompt: Check active DHCP leases Source: https://github.com/alikarami/mikromcp/wiki/Getting-Started Example prompt to paste into your AI assistant to verify the MikroMCP connection. Expect the assistant to call MikroMCP tools and return real data from your router. ```text Are there any active DHCP leases? ``` -------------------------------- ### Example fingerprint output Source: https://github.com/alikarami/mikromcp/wiki/RouterOS-API-Setup Example output from the openssl command showing the SHA256 fingerprint format. ```text SHA256 Fingerprint=AA:BB:CC:DD:... ``` -------------------------------- ### Create config/identities.example.yaml Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-14-v0.7-identity-auth-audit.md Example YAML configuration defining identities with bcrypt-hashed tokens and RBAC policies. Includes token generation instructions and role descriptions. ```yaml # MikroMCP Identity Configuration # # Each identity maps a bcrypt-hashed bearer token to an RBAC policy. # Roles are semantic labels; enforcement is via allowedRouters and allowedToolPatterns. # # Token generation (two steps): # 1. Generate raw token: openssl rand -hex 32 # 2. Hash it (bcrypt cost 12): # node -e "const b=require('bcryptjs');b.hash(process.argv[1],12).then(console.log)" # # Store the raw token securely (password manager, secrets vault). # Only the bcrypt hash goes in this file — never the raw token. # # Roles: readonly | operator | admin | superadmin # - readonly: Read-only tools. Requires confirmation for any destructive tool. # - operator: Read + selected write tools. Requires confirmation for destructive tools. # - admin: Full access. Skips confirmation gate. # - superadmin: Full access. Same as admin but typically used for the built-in stdio identity. # # allowedRouters: [] means all routers are accessible. # allowedToolPatterns: [] means all tools are accessible. Supports * wildcard. identities: # CI pipeline: read-only access to specific routers, limited tool set ci-pipeline: token: "$2b$12$REPLACE_WITH_BCRYPT_HASH_OF_YOUR_TOKEN" role: operator allowedRouters: - edge-01 - edge-02 allowedToolPatterns: - "list_*" - "ping" - "traceroute" - "get_system_status" # Admin user: full access to all routers and tools, skips confirmation gate admin-ali: token: "$2b$12$REPLACE_WITH_BCRYPT_HASH_OF_YOUR_TOKEN" role: admin allowedRouters: [] # empty = all routers allowedToolPatterns: [] # empty = all tools ``` -------------------------------- ### Production build and start Source: https://github.com/alikarami/mikromcp/wiki/Running Builds to `dist/main.js` (ESM via tsup) and runs it with Node. Equivalent to `mikromcp serve` from the npm install. ```bash npm run build npm start ``` -------------------------------- ### Clone and install from source Source: https://github.com/alikarami/mikromcp/wiki/Running Clone the MikroMCP repository and install dependencies with npm. ```bash git clone https://github.com/AliKarami/MikroMCP.git cd MikroMCP npm install ``` -------------------------------- ### npm scripts for development, build, test, and lint Source: https://github.com/alikarami/mikromcp/wiki/Development Lists the available npm scripts for development, including hot-reload, build, start, testing, type checking, linting, and formatting. Run `npm test` before pushing a branch; it runs vitest, tsc, and eslint together, including doc-accuracy guards and skill tool-map lockstep. ```bash npm run dev # tsx watch — hot-reload during development npm run build # tsup → dist/main.js (ESM) npm start # run built server (stdio mode) npm test # vitest + tsc + eslint (run once) npm run test:watch # vitest in watch mode npm run test:integration # integration tests against a live RouterOS CHR (Docker) npm run typecheck # tsc --noEmit npm run lint # eslint src/ npm run format # prettier --write src/ test/ npm run format:check # prettier --check src/ test/ (CI runs this) ``` -------------------------------- ### Build and run Docker container Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-19-v1.0-distribution-onboarding.md Builds the Docker image and runs the container to verify it starts. ```bash docker build -t mikromcp:test . && docker run --rm mikromcp:test ``` -------------------------------- ### Install basic-ftp Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-13-v0.6-automation.md Installs the basic-ftp package via npm. After running, basic-ftp should appear in package.json dependencies. ```bash npm install basic-ftp ``` -------------------------------- ### Install the tested worktree package globally Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-09-03-ssh-key-auth.md Install the tested worktree package globally using an absolute path. ```bash npm install --global /absolute/path/to/mikromcp-worktree ``` -------------------------------- ### Install bcryptjs and types Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-14-v0.7-identity-auth-audit.md Installs bcryptjs and its TypeScript types in the project directory. Requires Node.js and npm. ```bash cd /Users/alikarami/Projects/MikroMCP npm install bcryptjs npm install -D @types/bcryptjs ``` -------------------------------- ### Build, run, and test HTTP transport with curl Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-04-24-v0.2.md Builds the project, starts the HTTP transport server on port 3001, sends an MCP initialize request via curl, and kills the background process. Expects a JSON response beginning with `{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":...`. Requires `config/routers.yaml` to exist; copy from example if missing. ```bash cd /Users/alikarami/Projects/MikroMCP && npm run build && \ MIKROMCP_TRANSPORT=http MIKROMCP_PORT=3001 \ MIKROMCP_CONFIG_PATH=config/routers.yaml \ node dist/main.js & sleep 1 curl -s -X POST http://localhost:3001/mcp \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1"}}}' | head -c 300 kill %1 2>/dev/null; true ``` ```bash cp config/routers.example.yaml config/routers.yaml 2>/dev/null || true ``` -------------------------------- ### Build both sites locally Source: https://github.com/alikarami/mikromcp/blob/main/CLAUDE.md Run these commands before pushing to catch template or link errors in the landing page and documentation site. ```bash npm --prefix site run build npm --prefix docs-site run build ``` -------------------------------- ### Commit ExamplesTabs component Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-31-landing-page.md Git commands to stage and commit the ExamplesTabs component and index page changes for the 'examples' section. ```bash git add site/src/components/ExamplesTabs.astro site/src/pages/index.astro git commit -m "feat(site): real-world example prompts with tabs" ``` -------------------------------- ### Commit command for QuickStart and index.astro Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-31-landing-page.md Git commands to stage and commit the new QuickStart component and the modified index.astro page. The commit message follows the conventional 'feat(site):' format. ```bash git add site/src/components/QuickStart.astro site/src/pages/index.astro git commit -m "feat(site): quick-start with install tabs and copy buttons" ``` -------------------------------- ### Add pointer to docs/wiki/Connecting-to-AI-Assistants.md Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-29-phase3-mikromcp-skill.md Markdown section to append at the end of the file, recommending installation of the usage skill for safe tool driving. ```markdown ## Usage skill For best results, install the MikroMCP usage skill so the assistant knows how to drive the tools safely (dry-run → confirm → rollback, fleet ops, diagnosis). See [Using the Skill](Using-the-Skill.md). ``` -------------------------------- ### Build and verify docs site Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-06-02-docs-site.md Runs the full build to verify the prebuild sync and Starlight output. Expects prebuild to print '[sync-wiki] wrote 15 pages' and the dist to contain index.html, architecture/index.html, and pagefind/. ```bash cd docs-site && npm run build ``` -------------------------------- ### ExamplesTabs.astro component Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-31-landing-page.md Astro component rendering example prompts as tabs with a toggle script. Imports examples from content.ts, uses a tablist with buttons and panels, and toggles active classes and aria-selected on click. ```astro --- import { examples } from "../data/content.ts"; ---

Real prompts, real operations

Paste these straight into your AI assistant.

{examples.map((e, i) => ( ))}
{examples.map((e, i) => (
{e.prompt}
))}
``` -------------------------------- ### Build and preview the site Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-31-landing-page.md Run the production build and preview server from the site directory. The build must succeed and the output must contain the expected JSON-LD, meta tags, sections, and static files. ```bash cd site && npm run build && npm run preview ``` -------------------------------- ### Build the site with npm Source: https://github.com/alikarami/mikromcp/blob/main/site/DEPLOY.md Run these commands in the `site/` directory to install dependencies and build the static Astro site. Output lands in `site/dist/`. ```bash cd site npm ci npm run build ``` -------------------------------- ### Create docs/wiki/Using-the-Skill.md Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-29-phase3-mikromcp-skill.md Markdown content for the new skill documentation page. It describes the MikroMCP skill, its installation, and its internal structure, linking to official MikroTik documentation. ```markdown # Using the MikroMCP Skill MikroMCP ships a Claude Code **skill** at `skills/mikromcp/` that teaches an AI assistant to drive the tools safely — picking the right tool, running dry-run → confirm → apply changes, fleet rollouts, and error recovery. It links to official MikroTik documentation rather than copying it. ## Install (personal use) Symlink (or copy) the skill into your Claude Code skills directory: ```bash ln -s "$PWD/skills/mikromcp" ~/.claude/skills/mikromcp # or: cp -r skills/mikromcp ~/.claude/skills/mikromcp ``` Restart Claude Code; the skill activates automatically when you work with MikroTik routers through MikroMCP. ## What's inside - `SKILL.md` — entry point: golden safety rules, intent→tool quick index, core workflows. - `references/tool-map.md` — every tool by family with its REST path. - `references/safety-and-recovery.md` — change lifecycle, idempotency, rollback, error→action table. - `references/routeros-docs.md` — curated links into help.mikrotik.com. The tool-map is kept in lockstep with the server's tools by a test in `test/unit/skill/tool-map-sync.test.ts` (runs under `npm test`). ``` -------------------------------- ### Clean build from scratch Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-06-02-docs-site.md Removes previous build artifacts and content, then rebuilds the docs site. Expects '[sync-wiki] wrote 15 pages' and a successful build without broken-link or missing-slug errors. ```bash cd docs-site && rm -rf dist src/content/docs && npm run build ``` -------------------------------- ### Unit test example with mock context Source: https://github.com/alikarami/mikromcp/blob/main/CLAUDE.md Shows the structure for a unit test in `test/unit/`, including a minimal mock context for `ToolContext` and `RouterOSRestClient`. Uses `vitest` and imports with `.js` extension. The mock `routerClient` provides `get`, `create`, and `remove` methods returning resolved promises. ```typescript import { describe, it, expect, vi } from "vitest"; import { myTools } from "../../../src/domain/tools/my-tools.js"; // .js extension const myTool = myTools[0]; // Build a minimal mock context function makeContext(records: Record[]): ToolContext { return { routerId: "test-router", correlationId: "test-corr", routerClient: { get: vi.fn().mockResolvedValue(records), create: vi.fn().mockResolvedValue({ ".id": "*1" }), remove: vi.fn().mockResolvedValue(undefined), } as unknown as RouterOSRestClient, }; } ``` -------------------------------- ### Write docs-site/DEPLOY.md (markdown) Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-06-02-docs-site.md Provides deployment instructions for the static Starlight build, noting that content is sourced from ../docs/wiki/*.md and transformed by scripts/sync-wiki.mjs via the prebuild hook. Warns not to edit src/content/docs/ as it is generated and git-ignored. ```markdown # Deploying the MikroMCP Docs Site Static Starlight build. Content comes from `../docs/wiki/*.md`, transformed at build time by `scripts/sync-wiki.mjs` (runs automatically via the `prebuild` hook). Edit docs in `docs/wiki/` as usual — never edit `src/content/docs/` (it is generated and git-ignored). ## 1. Build ```bash cd docs-site npm ci npm run build ``` Output lands in `docs-site/dist/`. ``` -------------------------------- ### manage_upgrade Source: https://github.com/alikarami/mikromcp/wiki/Available-Tools Triggers a RouterOS package update check or starts an upgrade installation. The `install` action causes a router reboot. ```APIDOC ## manage_upgrade ### Description Trigger a RouterOS package update check or start an upgrade installation. The `install` action causes a router reboot. ### Parameters #### Parameters - **routerId** (string) - Required - Target router identifier - **action** (enum) - Required - `check` (non-destructive) or `install` (destructive, reboots) - **dryRun** (boolean) - Optional - Preview without executing (default: false) ### Response #### Success Response Returns the result of the upgrade check or installation. ### Example Prompt "Check for RouterOS upgrades on router border-r1, then install if a newer version is available" ``` -------------------------------- ### Run init wizard Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-19-v1.0-distribution-onboarding.md Runs the init wizard and generates routers.yaml. ```bash node dist/main.js init ``` -------------------------------- ### Changelog entry example Source: https://github.com/alikarami/mikromcp/blob/main/CLAUDE.md Example of a release section in CHANGELOG.md following Keep a Changelog format. Sections used: `Added` and `Fixed`. Each release section covers only changes since the previous release. ```markdown ## [1.1.0] - 2026-06-01 ### Added - `list_wifi_clients` tool — lists associated WiFi stations per interface - `manage_wifi_interface` tool — enable/disable WiFi interfaces ### Fixed - Circuit breaker no longer trips on 404 responses from read tools ``` -------------------------------- ### Get TLS fingerprint with openssl Source: https://github.com/alikarami/mikromcp/wiki/RouterOS-API-Setup Retrieves the SHA-256 fingerprint of the server certificate for pinning. Replace 10.0.0.1 with the router's address. ```bash openssl s_client -connect 10.0.0.1:443 -showcerts /dev/null \ | openssl x509 -fingerprint -sha256 -noout ``` -------------------------------- ### Deploy with rsync Source: https://github.com/alikarami/mikromcp/blob/main/site/DEPLOY.md Sync the built `site/dist/` directory to the server. The `--delete` flag removes stale files to keep the server in sync. Adjust the user/host/path. ```bash rsync -avz --delete site/dist/ user@your-hetzner-host:/var/www/mikromcp.com/ ``` -------------------------------- ### Environment variables for router credentials Source: https://github.com/alikarami/mikromcp/wiki/Getting-Started Companion `.env` file for the manual config. Provides the username and password referenced by the `envPrefix` in `routers.yaml`. ```bash ROUTER_CORE01_USER=mcp-api ROUTER_CORE01_PASS=choose-a-strong-password ``` -------------------------------- ### HTTP transport error handling and server startup Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-14-v0.7-identity-auth-audit.md Handles 404, 413, and 500 errors for the HTTP transport, then starts the server. Used in the HTTP transport setup. ```typescript res.writeHead(404, { "Content-Type": "application/json" }); res.end( JSON.stringify({ error: "Not found.", endpoints: { streamableHttp: "POST /mcp or GET /mcp", legacySse: "GET /sse then POST /messages?sessionId=", }, }), ); } catch (err) { if (err instanceof BodyTooLargeError) { if (!res.headersSent) { res.writeHead(413, { "Content-Type": "application/json" }); res.end(JSON.stringify({ error: "Request body too large" })); } return; } log.error({ err }, "HTTP transport error"); if (!res.headersSent) { res.writeHead(500, { "Content-Type": "application/json" }); res.end(JSON.stringify({ error: "Internal server error" })); } } }); await new Promise((resolve, reject) => { httpServer.listen(port, bindHost, () => { log.info( { port, bindHost }, "HTTP transport listening (POST /mcp for Streamable HTTP, GET /sse for legacy SSE)", ); resolve(); }); httpServer.on("error", reject); }); } ``` -------------------------------- ### Enable nginx site and reload Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-06-02-docs-site.md Creates a symlink to enable the docs site in nginx, then tests the configuration and reloads nginx if the test passes. ```bash sudo ln -s /etc/nginx/sites-available/docs.mikromcp.com /etc/nginx/sites-enabled/ sudo nginx -t && sudo systemctl reload nginx ``` -------------------------------- ### Example successful REST API response Source: https://github.com/alikarami/mikromcp/wiki/RouterOS-API-Setup Example JSON response from the REST API showing system resource information. A 401 indicates wrong credentials, 403 means the user lacks rest-api policy, and connection refused indicates the service is not running or firewall is blocking. ```json { "architecture-name": "arm64", "board-name": "RB5009UG+S+", "cpu": "ARM", "cpu-frequency": "1400", "cpu-load": "3", "free-memory": "512000000", "uptime": "1d2h30m", "version": "7.14.1 (stable)" } ``` -------------------------------- ### Enable and reload nginx Source: https://github.com/alikarami/mikromcp/blob/main/site/DEPLOY.md Symlink the server block into `sites-enabled/`, test the configuration, and reload nginx. ```bash sudo ln -s /etc/nginx/sites-available/mikromcp.com /etc/nginx/sites-enabled/ sudo nginx -t && sudo systemctl reload nginx ``` -------------------------------- ### get(path, options?) Source: https://github.com/alikarami/mikromcp/blob/main/CLAUDE.md Retrieves a list of records from the specified RouterOS path. Supports optional filtering, property selection, and pagination parameters. ```APIDOC ## get(path, options?) ### Description Retrieves a list of records from the specified RouterOS path. Supports optional filtering, property selection, and pagination parameters. ### Method GET ### Endpoint `get(path: string, options?: { filter?, proplist?, limit?, offset? }): Promise` ### Parameters #### Path Parameters - **path** (string) - Required - The RouterOS API path to query. #### Query Parameters - **filter** (object) - Optional - Filter criteria for the query. - **proplist** (array) - Optional - List of properties to include in the response. - **limit** (number) - Optional - Maximum number of records to return. - **offset** (number) - Optional - Number of records to skip before starting to return results. ### Response #### Success Response (200) - **T[]** (array) - Array of records of type T. ``` -------------------------------- ### Verify build output (bash) Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-06-02-docs-site.md Runs the docs-site build and checks that favicon.png, robots.txt, and sitemap-index.xml exist in the dist directory. Starlight emits sitemap-index.xml automatically. ```bash cd docs-site && npm run build && ls dist/favicon.png dist/robots.txt dist/sitemap-index.xml ``` -------------------------------- ### Create placeholder docs-site/src/content/docs/index.md Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-06-02-docs-site.md Temporary placeholder so the first install/build can run. The build runs prebuild (the sync script) which does not exist until Task 2, so this placeholder is needed to verify scaffolding in isolation. ```markdown --- title: MikroMCP Docs --- Placeholder. ``` -------------------------------- ### Run fleet tests with second CHR Source: https://github.com/alikarami/mikromcp/wiki/Development Starts a second CHR using the 'pair' profile and runs integration tests with MIKROMCP_ITEST_PAIR=1. Skipped by default; CI always runs with both routers. ```bash docker compose -f docker-compose.test.yml --profile pair up -d MIKROMCP_ITEST_PAIR=1 npm run test:integration ``` -------------------------------- ### OpenVPN tools test file with setup and metadata tests Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-23-v1.3.md Creates the unit test file for OpenVPN tools. Includes helper functions to build RouterConfig and ToolContext, imports the four tools, and tests metadata like names, readOnly/destructive hints, and snapshotPaths. ```typescript import { describe, it, expect, vi } from "vitest"; import { z } from "zod"; import { ovpnTools } from "../../../src/domain/tools/ovpn-tools.js"; import type { ToolContext } from "../../../src/domain/tools/tool-definition.js"; import type { RouterOSRestClient } from "../../../src/adapter/rest-client.js"; import type { RouterConfig } from "../../../src/types.js"; import type { SshClient } from "../../../src/adapter/ssh-client.js"; import type { FtpClient } from "../../../src/adapter/ftp-client.js"; import { ErrorCategory } from "../../../src/domain/errors/error-types.js"; function makeRouterConfig(): RouterConfig { return { id: "test-router", host: "192.168.1.1", port: 443, tls: { enabled: true, rejectUnauthorized: false }, credentials: { source: "env", envPrefix: "ROUTER_TEST" }, tags: [], rosVersion: "7", }; } function makeContext( records: Record[] = [], overrides: Partial = {}, ): ToolContext { return { routerId: "test-router", correlationId: "test-corr", routerConfig: makeRouterConfig(), identity: { id: "superadmin-builtin", role: "superadmin" as const, allowedRouters: [], allowedToolPatterns: [] }, sshClient: { execute: vi.fn().mockResolvedValue("") } as unknown as SshClient, ftpClient: { upload: vi.fn().mockResolvedValue(undefined), connect: vi.fn().mockResolvedValue(undefined), } as unknown as FtpClient, routerClient: { get: vi.fn().mockResolvedValue(records), create: vi.fn().mockResolvedValue({ ".id": "*1", name: "ovpn-client1" }), update: vi.fn().mockResolvedValue(undefined), remove: vi.fn().mockResolvedValue(undefined), ...overrides, } as unknown as RouterOSRestClient, }; } const [listClientsTool, manageClientTool, getServerTool, manageServerTool] = ovpnTools; const sampleServer = { ".id": "*0", enabled: "yes", port: "1194", mode: "ip", protocol: "tcp-server", certificate: "server-cert", cipher: "aes256-cbc", auth: "sha1", }; describe("ovpnTools", () => { describe("metadata", () => { it("exports exactly 4 tools", () => expect(ovpnTools).toHaveLength(4)); it("has correct names", () => { expect(ovpnTools.map((t) => t.name)).toEqual([ "list_ovpn_clients", "manage_ovpn_client", "get_ovpn_server", "manage_ovpn_server", ]); }); it("list_ovpn_clients is readOnly", () => expect(listClientsTool.annotations.readOnlyHint).toBe(true)); it("get_ovpn_server is readOnly", () => expect(getServerTool.annotations.readOnlyHint).toBe(true)); it("manage_ovpn_client is not readOnly and is destructive", () => { expect(manageClientTool.annotations.readOnlyHint).toBe(false); expect(manageClientTool.annotations.destructiveHint).toBe(true); }); it("manage_ovpn_server is not readOnly and is destructive", () => { expect(manageServerTool.annotations.readOnlyHint).toBe(false); expect(manageServerTool.annotations.destructiveHint).toBe(true); }); it("manage_ovpn_client has snapshotPaths", () => expect(manageClientTool.snapshotPaths).toContain("interface/ovpn-client")); it("manage_ovpn_server has snapshotPaths", () => expect(manageServerTool.snapshotPaths).toContain("interface/ovpn-server/server")); }); describe("list_ovpn_clients input schema", () => { const schema = z .object({ routerId: z.string(), limit: z.number().int().min(1).max(500).default(100), offset: z.number().int().min(0).default(0), }) .strict(); it("applies defaults", () => { const r = schema.parse({ routerId: "r1" }); expect(r.limit).toBe(100); expect(r.offset).toBe(0); }); it("rejects extra fields", () => { expect(() => schema.parse({ routerId: "r1", bogus: true })).toThrow(); }); }); describe("handler - list_ovpn_clients", () => { const clients = [ { ".id": "*1", name: "ovpn-hq", "connect-to": "10.0.0.1", running: true }, { ".id": "*2", name: "ovpn-branch", "connect-to": "10.0.0.2", running: false }, ]; ``` -------------------------------- ### Test RouterOS REST API with curl Source: https://github.com/alikarami/mikromcp/wiki/Getting-Started Directly test against the RouterOS REST API using curl with the mcp-api user and password. The command fetches system resource information and formats it with python3 -m json.tool. ```bash curl -sk https://10.0.0.1/rest/system/resource \ --user mcp-api:your-password | python3 -m json.tool ``` -------------------------------- ### Full Starlight config for astro.config.mjs Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-06-02-docs-site.md Replaces astro.config.mjs with the complete Starlight configuration including site URL, title, description, logo, favicon, custom CSS, social links, and sidebar navigation. The sidebar groups pages under Getting started, Connect an assistant, Reference, and Contributing. ```JavaScript import { defineConfig } from "astro/config"; import starlight from "@astrojs/starlight"; export default defineConfig({ site: "https://docs.mikromcp.com", integrations: [ starlight({ title: "MikroMCP Docs", description: "Documentation for MikroMCP — an MCP server exposing MikroTik RouterOS as 117 typed, auditable tools for AI assistants.", logo: { src: "./public/assets/MikroMCP-logo-transparent.png", alt: "MikroMCP", replacesTitle: false, }, favicon: "/favicon.png", customCss: ["./src/styles/custom.css"], social: [ { icon: "github", label: "GitHub", href: "https://github.com/AliKarami/MikroMCP" }, { icon: "external", label: "Main site", href: "https://mikromcp.com" }, ], sidebar: [ { label: "Getting started", items: [ { label: "Getting Started", slug: "getting-started" }, { label: "RouterOS API Setup", slug: "routeros-api-setup" }, { label: "Configuration", slug: "configuration" }, { label: "Running", slug: "running" }, ], }, { label: "Connect an assistant", items: [ { label: "Claude Desktop", slug: "connecting-to-claude-desktop" }, { label: "AI Assistants", slug: "connecting-to-ai-assistants" }, { label: "Using the Skill", slug: "using-the-skill" }, ], }, { label: "Reference", items: [ { label: "Available Tools", slug: "available-tools" }, { label: "Architecture", slug: "architecture" }, { label: "Error Handling", slug: "error-handling" }, { label: "Security", slug: "security" }, ], }, { label: "Contributing", items: [ { label: "Development", slug: "development" }, { label: "Contributing", slug: "contributing" }, { label: "Roadmap", slug: "roadmap" }, ], }, ], }), ], }); ``` -------------------------------- ### Run documentation and tool-map sync tests Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-09-03-ssh-key-auth.md Runs the documentation and skill tool-map sync unit tests. ```bash npx vitest run test/unit/docs test/unit/skill/tool-map-sync.test.ts ``` -------------------------------- ### Test: /healthz returns 200 without auth Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-21-v1.1.0-release.md Adds a test to http-hardening.test.ts that starts the transport and GETs /healthz, expecting 200 and JSON body { status: "ok" }. Reuses the existing harness in the file. The test fails initially because /healthz returns 404. ```typescript it("serves /healthz with 200 and does not require auth", async () => { // Use the same harness the other tests in this file use to drive connectHttp. // GET /healthz with no Authorization header. // Expect: status 200, JSON body { status: "ok" }. }); ``` -------------------------------- ### Clone and link the MikroMCP usage skill Source: https://github.com/alikarami/mikromcp/wiki/Getting-Started Links the MikroMCP usage skill into Claude Code from a local clone. Requires a Git clone of the repository; the skill is not included in the npm package. Restart Claude Code after linking; the skill activates automatically and can be invoked with /mikromcp. ```bash git clone https://github.com/AliKarami/MikroMCP.git ln -s "$PWD/MikroMCP/skills/mikromcp" ~/.claude/skills/mikromcp ``` -------------------------------- ### Run tests to verify they fail Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-14-v0.7-identity-auth-audit.md Command to run the adapter-factory unit tests. Expected to fail with a module not found error because the implementation file does not exist yet. ```bash npm test -- test/unit/adapter/adapter-factory.test.ts ``` -------------------------------- ### Create Nav.astro component with sticky navigation and mobile toggle Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-31-landing-page.md Creates the navigation component with transparent-over-hero styling, solid on scroll via a .scrolled class, and a mobile hamburger toggling .open. Includes links to Features, How it works, Tools, FAQ, Docs, GitHub, and a Get Started button. Uses SITE.docs and SITE.github from content.ts. ```astro --- import { SITE } from "../data/content.ts"; --- ``` -------------------------------- ### Test: manage_upgrade install calls install endpoint Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-24-v1.4.md Unit test for manageTool.handler with action 'install' verifying it calls the install endpoint and returns action 'install_triggered'. ```typescript it("calls install endpoint", async () => { const ctx = makeContext(); const result = await manageTool.handler({ routerId: "test-router", action: "install" }, ctx); const sc = result.structuredContent as Record; expect(sc.action).toBe("install_triggered"); expect(ctx.routerClient.execute).toHaveBeenCalledWith("system/package/update/install"); }); ``` -------------------------------- ### Enable RouterOS REST API with self-signed certificate Source: https://github.com/alikarami/mikromcp/wiki/Getting-Started Run these RouterOS CLI commands to enable the HTTPS REST API for MikroMCP. Replace 10.0.0.1 with the router address and choose a strong password. For read-only access, use group=read instead of group=full. The certificate is self-signed, so MikroMCP connects with rejectUnauthorized: false; pin its fingerprint with tls.fingerprint before production use. ```routeros /certificate add name=rest-cert common-name=10.0.0.1 subject-alt-name=IP:10.0.0.1 key-usage=digital-signature,key-encipherment,tls-server days-valid=825 /certificate sign rest-cert /ip service set www-ssl certificate=rest-cert port=443 disabled=no /user add name=mcp-api group=full password=choose-a-strong-password ``` -------------------------------- ### Run snapshot engine tests (Step 2) Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-17-v0.8-change-safety-rollback.md Command to run the snapshot engine tests. Expected to fail initially because the module is not yet implemented. ```bash npm test -- test/unit/domain/snapshot/snapshot-engine.test.ts ``` -------------------------------- ### Deploy docs site with rsync Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-06-02-docs-site.md Pushes the built docs site to the Hetzner server. Uses rsync with archive, verbose, and compression flags, and deletes files on the server that are not in the local dist directory. ```bash rsync -avz --delete docs-site/dist/ user@your-hetzner-host:/var/www/docs.mikromcp.com/ ``` -------------------------------- ### Run upgrade-tools tests Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-24-v1.4.md Command to run the unit tests for upgrade-tools. Expected to fail initially because the module is not yet implemented. ```bash npx vitest run test/unit/domain/upgrade-tools.test.ts ``` -------------------------------- ### Test: starts a stopped container Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-05-13-v0.6-automation.md Verifies that the handler starts a stopped container and calls execute with the correct endpoint. ```typescript it("starts a stopped container", async () => { const execute = vi.fn().mockResolvedValue({}); const ctx = makeContext({ get: vi.fn().mockResolvedValue([{ ".id": "*1", name: "app", status: "stopped" }]), execute, }); const result = await manageContainerTool.handler( { routerId: "test-router", action: "start", name: "app" }, ctx, ); expect((result.structuredContent as Record).action).toBe("started"); expect(execute).toHaveBeenCalledWith("container/*1/start"); }); ``` -------------------------------- ### Build the project Source: https://github.com/alikarami/mikromcp/blob/main/docs/superpowers/plans/2026-09-03-ssh-key-auth.md Build the project after tests pass. ```bash npm run build ```