opn-mcp Server

अपने AI सहायक से लिंक छोटा करें, क्लिक एनालिटिक्स पढ़ें, और opn.onl शॉर्ट लिंक (होस्टेड या सेल्फ-होस्टेड) प्रबंधित करें।

दस्तावेज़

opn-mcp

An MCP server for opn.onl — the open-source, self-hostable URL shortener. It lets AI assistants (Claude Desktop, Cursor, etc.) shorten links, read analytics, generate QR codes, and manage links in natural language.

Works against the hosted service or your own self-hosted instance.

Setup

1. Get an API key

On your opn.onl instance, go to Settings → API Keys, create a key, and copy it (it starts with opn_ and is shown once).

2. Add the server to your MCP client

Claude Desktop — edit claude_desktop_config.json (~/Library/Application Support/Claude/ on macOS, %APPDATA%\Claude\ on Windows):

{
  "mcpServers": {
    "opn": {
      "command": "npx",
      "args": ["-y", "opn-mcp"],
      "env": {
        "OPN_API_KEY": "opn_your_key_here"
      }
    }
  }
}

Restart your client. That's it — it talks to the hosted API (https://l.opn.onl) by default.

Not published to npm yet? Use the GitHub source instead — same config, just swap the args: "args": ["-y", "github:ysalitrynskyi/opn-mcp"] (it builds on install).

Self-hosted instance

Point OPN_BASE_URL at your own instance's API host:

{
  "mcpServers": {
    "opn": {
      "command": "npx",
      "args": ["-y", "opn-mcp"],
      "env": {
        "OPN_API_KEY": "opn_your_key_here",
        "OPN_BASE_URL": "https://l.your-domain.com"
      }
    }
  }
}

Configuration

Env varRequiredDefaultDescription
OPN_API_KEYYour API key (opn_…), from Settings → API Keys
OPN_BASE_URLhttps://l.opn.onlAPI base URL — set this for a self-hosted instance

Tools

ToolDescription
shorten_urlCreate a short link (url, optional alias / title / expiry / password)
list_linksList your links (limit, offset, search)
get_link_statsClick analytics for a link (geo, devices, browsers, referrers)
update_linkUpdate a link's destination, title, expiry or password
delete_linkDelete a link
get_qr_codeGet a link's QR image — optional brand colour, centre logo, PNG/SVG
check_url_healthCheck a destination URL is reachable before shortening

Example prompts

  • "Shorten https://example.com/very/long/url and call it launch-2026"
  • "How many clicks did link 42 get, and from which countries?"
  • "Give me a branded SVG QR code for link 42"
  • "List my last 10 links"

Development

npm install
npm run build      # tsc → dist/
npm test           # vitest
OPN_API_KEY=opn_… npm run dev   # run from source (stdio)

License

MIT © ysalitrynskyi. Part of the opn.onl project.