← Blog
MCP2 min read

Shorten a URL with a URL shortener API: the complete guide

The KooLink API shortens a URL in one POST, works anonymously, and has no free-tier cap. A complete, copy-pasteable guide to the endpoints, plus how it connects to MCP.

A URL shortener API is the difference between "a link shortener" and "a tool you can build on." If you want to shorten URLs from code — a script, a CLI, a wire-up, an automation — you need an endpoint you can call and a JSON response you can parse.

Here is the complete KooLink API guide.

The endpoint

POST https://kool.ink/api/links

Content-Type: application/json

It works anonymously. No API key, no account, no free-tier cap. Turn up and shorten.

Shorten a URL

curl -X POST https://kool.ink/api/links \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/very/long/path"}'

If you pass the Googlebot user-agent (some hosts require it, and it's good practice):

curl -X POST https://kool.ink/api/links \
  -H "Content-Type: application/json" \
  -H "User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" \
  -d '{"url": "https://example.com/very/long/path"}'

Response:

{ "shortUrl": "https://kool.ink/9BVmkm" }

shortUrl is the compact link you share. That is the whole API.

What the API is good for

  • Scripts and CLI tools. Shorten URLs from a shell script, a cron job, or a build step.
  • Automation. A tool that mints short links on demand — a deploy script, a bot, an internal dashboard.
  • Composability. Fold it into a larger pipeline, because shortUrl comes back as clean JSON.

The AI-agent angle: MCP

A REST API is what your code calls. An MCP server is what your agent uses. KooLink offers both, so you do not have to pick based on the integration you are building today.

Point your MCP client (Claude, Cursor, Windsurf, VS Code with Continue) at:

https://mcp.kool.ink

The agent gets a shorten_url tool. Ask it to shorten any URL and it does — one call, no browser, no copy-paste, no API key.

There is also a terminal one-liner:

npx @koolink/koolink https://example.com/very/long/path
# → https://kool.ink/xyz

Pipe a URL in:

echo "https://example.com/long" | npx @koolink/koolink
# → https://kool.ink/xyz

Status codes and errors

  • 200 — link created, returned in shortUrl.
  • 400 — bad request (e.g. missing or invalid URL).
  • A malformed or non-http URL is rejected.

Rules of a good shortener API

  • Anonymous. No key to mint or rotate.
  • Unlimited. No cap an automation hits at 9am on a Tuesday.
  • Permanent. Links that do not expire.
  • Clean JSON. So parsing is trivial in any language.

KooLink is the only widely-used shortener that has all of that plus a hosted MCP server for your agent.

Try it

  • From code: POST https://kool.ink/api/links with { "url": "..." }
  • From your agent: point it at https://mcp.kool.ink
  • From your terminal: npx @koolink/koolink https://example.com/long/path

Free forever. Unlimited. No signup.