Skip to main content
Glama
lnkify

lnkify

Official
by lnkify
README.md
<div align="center">

# 🔗 lnkify CLI

**Not just a URL Shortener. Open Source, fully customizable.**

Manage your [Lnkify](https://lnkify.io) links, domains, API keys, and analytics
straight from the terminal — and plug Lnkify into any AI agent over MCP.

</div>

---

## Install

```bash
npm install -g lnkify
# or run without installing
npx lnkify --help
```

Requires Node.js >= 22.

## Quickstart

```bash
# 1. Point at your server (defaults to http://localhost:4000)
lnkify config set url http://localhost:4000

# 2. Authenticate — interactive login...
lnkify login
# ...or use a scoped API key (lf_live_…)
lnkify config set api-key lf_live_xxxxxxxxxxxx

# 3. Create and manage links
lnkify links create https://example.com --slug launch --track
lnkify links list
lnkify resolve launch
lnkify analytics
```

## Connecting to a server

The CLI is **local-first** (defaults to `http://localhost:4000`) but talks to any
Lnkify instance, local or remote. The host and credentials are resolved with this
precedence (highest wins):

1. **Flags** — `--url`, `--api-key`
2. **Environment** — `LNKIFY_API_URL`, `LNKIFY_API_KEY`
3. **Active profile** — selected with `--profile <name>` (else the default profile)
4. **Built-in default** — `http://localhost:4000`

### Profiles (multiple servers)

```bash
lnkify --profile prod config set url https://links.acme.com
lnkify --profile prod config set api-key lf_live_xxxx
lnkify --profile prod links list          # hit prod
lnkify links list                         # hit local default
```

Config lives at `~/.config/lnkify/config.json` (honors `$XDG_CONFIG_HOME`) and is
written with `0600` permissions because it holds secrets.

## Commands

| Command | Description |
| --- | --- |
| `lnkify login` / `logout` / `whoami` | Authenticate and inspect the current user |
| `lnkify config set\|get\|list` | Manage URL, API key, and profiles |
| `lnkify links create <target>` | Create a short link (`--slug`, `--title`, `--track`, `--domain`, `--rule`) |
| `lnkify links list` | List links (`--search`, `--take`, `--skip`, `--page`) |
| `lnkify links get\|update\|delete <id>` | Inspect, edit, or remove a link |
| `lnkify links bulk <create\|update\|delete> --file` | Bulk import from JSON/CSV (`--dry-run`) |
| `lnkify resolve <slug>` | Resolve a slug to its destination |
| `lnkify analytics` | Aggregate totals and top links |
| `lnkify domains add\|list\|verify\|rm` | Manage custom domains |
| `lnkify apikeys create\|list\|revoke` | Manage API keys |
| `lnkify mcp serve` | Run the CLI as a stdio MCP server for AI agents |
| `lnkify mcp install` | Print/write an MCP client config snippet |

Add `--json` to any command for clean, pipeable machine output:

```bash
lnkify links list --json | jq '.items[].lnkify'
```

## AI agents (MCP)

`lnkify mcp serve` exposes your links as Model Context Protocol tools over stdio, so
agents like Claude can create and manage short links on your behalf using your
configured credentials.

```bash
lnkify mcp install --client claude   # prints a ready-to-paste config block
```

## Development

```bash
pnpm install
pnpm dev          # tsup --watch
pnpm build
pnpm test         # node:test via tsx
pnpm lint
pnpm typecheck
```

## Contributing

Contributions are welcome — see [CONTRIBUTING.md](./CONTRIBUTING.md) for setup,
project layout, and the checks to run before opening a PR.

## License

MIT © [Mohit Yadav](https://lnkify.io)