# Linkly AI CLI [![LinklyAI/linkly-ai-cli MCP server](https://glama.ai/mcp/servers/LinklyAI/linkly-ai-cli/badges/score.svg)](https://glama.ai/mcp/servers/LinklyAI/linkly-ai-cli) [![Linkly AI MCP connector](https://glama.ai/mcp/connectors/ai.linkly.mcp/linkly-ai/badges/score.svg)](https://glama.ai/mcp/connectors/ai.linkly.mcp/linkly-ai) Search and read the documents on your computer from the terminal, or give an AI agent the same access over MCP. ## What is it? [Linkly AI](https://linkly.ai) is a desktop app for macOS, Windows and Linux that indexes the folders you choose: PDF, Word, PowerPoint, Excel, CSV, EPUB, RTF, Markdown, text, HTML, images (OCR), audio and video (speech transcription). The index stays on your computer, and every local feature is free without an account. `linkly` is its command line. It talks to the running desktop app, so there is nothing to index twice. **Use it to:** - search your files by keyword or by question, and read the result in the terminal or in scripts (`--json`) - let an agent with a terminal, such as Claude Code or Codex, search your files; the [official skill](https://github.com/LinklyAI/linkly-ai-skills) teaches it how - connect any MCP client over stdio with `linkly mcp` **How it differs from `grep` and `find`:** it reads inside PDFs, Office files, scans and recordings, matches meaning as well as keywords, and returns outlines so an agent can read only the sections it needs. ## Quick Start 1. [Download the desktop app](https://linkly.ai) and add a folder. 2. Install the CLI ([all options](#installation)): ```bash curl -sSL https://updater.linkly.ai/cli/install.sh | sh ``` 3. Search: ```bash linkly search "quarterly report" ``` ## Prerequisites By default, the **Linkly AI desktop app** must be running with MCP server enabled. The CLI automatically discovers the app via `~/.linkly/port`. Alternatively, use LAN mode (`--lan` with a saved LAN token) or Remote mode (`--remote` with a saved API key) — see [Connection Modes](#connection-modes). ## Installation ### macOS / Linux ```bash curl -sSL https://updater.linkly.ai/cli/install.sh | sh ``` ### Windows (PowerShell) ```powershell irm https://updater.linkly.ai/cli/install.ps1 | iex ``` ### Homebrew (macOS / Linux) ```bash brew tap LinklyAI/tap brew install linkly ``` ### Cargo ```bash cargo install linkly-ai-cli ``` ### GitHub Releases Pre-built binaries for all platforms are available on the [Releases](https://github.com/LinklyAI/linkly-ai-cli/releases) page. | Platform | File | | --------------------- | ----------------------------------------- | | macOS (Apple Silicon) | `linkly-aarch64-apple-darwin.tar.gz` | | macOS (Intel) | `linkly-x86_64-apple-darwin.tar.gz` | | Linux (x86_64) | `linkly-x86_64-unknown-linux-gnu.tar.gz` | | Linux (ARM64) | `linkly-aarch64-unknown-linux-gnu.tar.gz` | | Windows (x64) | `linkly-x86_64-pc-windows-msvc.zip` | ### From Source ```bash cargo install --path . ``` ## Usage ### Find Paths Locate folder candidates when you only know a fuzzy or cross-language container name (e.g. "WeChat" but the actual path contains `xinWeChat`). Pass several variants in `--patterns` so the keywords are OR-matched in a single call. Output is intended as a `--path-glob` source for `linkly search`. ```bash linkly find-paths --patterns "WeChat,微信,wxid" linkly find-paths --patterns "Notion,notion" --library my-research linkly find-paths --patterns "Dropbox" --limit 5 ``` | Option | Description | | ------------------- | -------------------------------------------------------------------------- | | `--patterns ` | Comma-separated keywords (OR-matched); ASCII case-insensitive, CJK literal | | `--library ` | Restrict to a specific library by name | | `--limit ` | Maximum folder candidates returned (default: 10, max: 50) | ### Analyze Your Files Count and measure the indexed files: how many, how big, how old, by type, folder, time and more. The answer is always JSON, computed from the index on each call; no document is opened. With no option it returns the summary alone. ```bash linkly analyze linkly analyze --sections types,folders linkly analyze --sections duplicates --path /Users/me/Documents linkly analyze --sections all --limit 20 ``` | Option | Description | | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `--sections ` | Comma-separated groups: `types`, `folders`, `time`, `content`, `keywords`, `duplicates`, `names`, `agents`, `collections`, `index`, `usage`, or `all` | | `--library ` | Restrict to one local library (a name or `local://`) | | `--path ` | Restrict to the files under this directory and its subfolders (absolute path) | | `--doc-types ` | Comma-separated document types, e.g. `pdf,md,image` | | `--modified-after ` | Only files modified at or after this ISO 8601 date or datetime (UTC) | | `--modified-before ` | Only files modified at or before this ISO 8601 date or datetime (UTC) | | `--limit ` | Entries per ranked list (default: 10, max: 50) | Local files only: a cloud library is not counted. A Desktop that does not have the tool yet answers `Unknown tool`; update Desktop. ### Search Documents ```bash linkly search "how does attention scale with sequence length?" linkly search "API design" --limit 5 linkly search "notes" --type pdf,md,docx,pptx,epub linkly search "attention" --library my-research linkly search "transformer" --path-glob "*.pdf" linkly search "quarterly report" --modified-after 2024-01-01 --modified-before 2024-12-31 linkly search "weekly notes" --time-sort newest --limit 10 ``` | Option | Description | | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `--limit ` | Maximum results (default: 20, max: 50) | | `--type ` | Filter by document types, comma-separated (e.g. `pdf,md,docx,pptx,epub,txt,html`) | | `--library ` | Restrict search to a specific library by name | | `--path-glob ` | Glob **substring-matched** against the file path — may appear anywhere, no leading/trailing `*` needed. `*` matches any chars (incl. `/`), `?` one char. Examples: `*.pdf`, `papers`, `/Users/me/notes/` (a full directory path scopes to that dir). When the actual path is unknown, run `linkly find-paths` first. | | `--modified-after ` | Inclusive lower bound on file modification time. Accepts a bare date (`2024-01-01`) or RFC 3339 (`2024-01-01T00:00:00Z`). UTC. Use for explicit windows like "after January 2024". | | `--modified-before ` | Inclusive upper bound. Same format as `--modified-after`. | | `--time-sort ` | Reorder by modification time: `newest` or `oldest`. Omit (default) to keep BM25 + vector relevance ordering. Use `newest` for "recent / latest" intent without a fixed window. | ### View Document Outline Get structural outlines for one or more documents (IDs come from search results): ```bash linkly outline linkly outline ``` ### Locate Lines in a Document ```bash linkly grep "pattern" linkly grep "error|warning" -C 3 -i linkly grep "TODO" --mode count ``` | Option | Description | | --------------- | -------------------------------------------- | | `-C, --context` | Lines of context before and after each match | | `-B, --before` | Lines of context before each match | | `-A, --after` | Lines of context after each match | | `-i` | Case-insensitive matching | | `--mode` | Output mode: `content` or `count` | | `--limit` | Maximum matches (default: 20, max: 100) | ### Read Document Content ```bash linkly read linkly read --offset 50 --limit 100 ``` | Option | Description | | -------------- | ---------------------------------- | | `--offset ` | Starting line number (1-based) | | `--limit ` | Number of lines to read (max: 500) | ### List Container Contents Enumerate a container without full-text matching — indexed files under a directory, one library's files, or your notes: ```bash linkly list --scope folder --path /Users/me/docs linkly list --scope folder # all watched roots linkly list --scope library --library "My Library" linkly list --scope notes --tags project --json ``` | Option | Description | | ------------------------------ | ------------------------------------------------------------------------ | | `--scope ` | Required: `folder`, `library`, or `notes` | | `--library ` | Which library to list (`--scope library`; a name or `local://`) | | `--path ` | Absolute directory to list (`--scope folder`, or inside a local library) | | `--type ` | Filter by document types, comma-separated (folder/library) | | `--modified-after/-before ` | Modification-time bounds, ISO 8601 UTC (folder/library) | | `--tags ` | Filter notes by tags, comma-separated, AND semantics (notes) | | `--sort ` | `recent` (default), `oldest`, or `name` | | `--limit` / `--offset` | Pagination (default 50, max 200; capped at 50 while snippets are on) | | `--snippet` / `--no-snippet` | Force per-item snippets on/off (default: notes on, folder/library off) | Notes live on the Desktop machine — with `--remote` the listing reaches them through the tunnel; there is no cloud notes store. ### Save a Note Create or edit a markdown card note in your Desktop's Notes folder: ```bash linkly note-save --mode create --content "Remember this #idea" echo "Piped body" | linkly note-save --mode create --content - linkly note-save --mode edit --note-id --base-version --content "New body #idea" ``` | Option | Description | | ----------------------- | ---------------------------------------------------------------------------- | | `--mode ` | `create` or `edit` (edit requires `--note-id` and `--base-version` together) | | `--content ` | Markdown body without YAML front matter; `-` reads it from stdin | | `--note-id ` | Which note to edit (from `linkly list --scope notes`) | | `--base-version ` | The version you read (compare-and-swap; from the same `list`) | | `--tags ` | Note tags (see the caution below before using this on edit) | | `--app-name ` | Hosting application's display name, shown as the note's source badge | Edits are compare-and-swap: a stale `--base-version` is rejected — re-read, merge, retry. Tags live in the note body as `#tokens` (the source of truth): `--tags` only **adds** tags, and you remove one by deleting its `#token` from the content. Caution: Desktops older than 0.11.0 instead require `--tags` on edit and treat it as the **full replacement set** (tags you omit are deleted). Requires Desktop >= 0.11.0. ### Check Status ```bash linkly status ``` ### MCP Bridge Mode Run as a stdio MCP server for Claude Desktop, Cursor, or other MCP clients: ```bash linkly mcp ``` Claude Desktop configuration (`claude_desktop_config.json`): ```json { "mcpServers": { "linkly-ai": { "command": "linkly", "args": ["mcp"] } } } ``` The bridge advertises the desktop's nine tools. With `--remote` (`"args": ["mcp", "--remote"]`) it also advertises the two cloud-only tools the gateway implements — `library_search` (find cloud libraries in the catalog, including ones not linked yet) and `library_link` (link one so `search` / `explore` / `list` can use it, or with `action: "unlink"` release a link the user named, e.g. when the Slot quota is full) — and the server instructions describe that reach. The local bridge never advertises them: the desktop does not implement them, so the tool list matches what the upstream can actually serve. Calls through the bridge carry the name the connecting application gives itself when it connects (Claude Desktop, for example, says `claude-ai`), so Desktop's access log shows which application read the documents; with `--remote` the name is sent to the gateway as well. `--client ` overrides it. The bridge starts even when it cannot connect yet — Desktop is not running, or there is no key for `--remote`. The tools are listed, and each call tries to connect again and reports what is missing. The bridge serves the desktop on this machine or the cloud gateway — it does not bridge to a desktop on the LAN. A client on another machine should connect to the desktop's LAN HTTP endpoint directly (copy the config from the desktop app's Agent usage → View MCP connection settings), or bridge with `--remote`. ### Diagnose Connection Issues ```bash linkly doctor # every connection this machine can use, grouped linkly doctor --remote # only the remote gateway linkly doctor --lan # only the saved LAN desktop linkly doctor --endpoint http://192.168.1.100:60606/mcp --token abc123 ``` Runs a series of checks (port file, server reachability, auth, MCP round-trip, and for a connected remote tunnel whether the desktop answers) and reports pass/fail with actionable advice. Without a flag it checks the local desktop and — when credentials for them are saved — the remote gateway and the LAN desktop at once, in separate groups, and succeeds when at least one connection works. A flag narrows the run to that one connection, in the same format. `--json` returns `{"status", "groups": [{"mode", "configured", "status", "checks", …}]}` either way; with a flag the earlier single-connection fields (`mode`, `checks`, `issues`, …) are also kept at the top level. ### List Libraries List all available knowledge libraries (useful with `search --library`): ```bash linkly list-libraries linkly list-libraries --remote ``` ### Read the Guide How to use Linkly AI from an agent: the workflow, search tips, every command, and fixes for errors. It is built into the binary, so it matches this version and works offline. `linkly mcp` offers the same guide as the `guide` tool. ```bash linkly guide # overview and contents linkly guide --search "time filter" # sections matching these words linkly guide workflow # one section, by its id ``` ### Self-Update ```bash linkly self-update ``` ### Agent Skill The `linkly-ai` skill teaches agents how to drive these tools. The CLI reports its version, installs it, and upgrades it in place: ```bash linkly skills status # installed version, latest published, and where it lives linkly skills install # download and install linkly skills update # upgrade an installed copy, or install a missing one ``` `linkly status` reports the skill in its main table, checked live on every run. That is the reliable place to look; everything below is the nudge for someone who did not think to look. When the skill is missing or out of date, output carries a one-line notice addressed to the assistant reading it — what is wrong, what it costs, and to ask the user before running the fix. It leads the output rather than trailing it, so a long result cannot bury it and a client that truncates cannot drop it. Under `--json` it arrives as a `skill_notice` field; over `linkly mcp` it is a separate content block ahead of the answer, sent once per process. A missing skill is reported on every run — deciding it costs one filesystem check, and throttling it means one unrelated process can silence it for every session in the next four hours. The out-of-date notices do read the update server, so those are throttled to once every four hours. To turn it all off: ```bash export LINKLY_NO_SKILLS_HINT=1 ``` `linkly mcp` inherits the environment, so setting it in an MCP client's config silences the bridge too. `update` follows the shape of each install: a symlink is left to the store it points at, a `git` checkout is reported rather than overwritten, and a real directory is replaced with the previous copy moved aside until the new one verifies. Only the `linkly-ai` subdirectory is ever touched — the surrounding skills directory belongs to whatever else you have installed there. Detection also looks at `linkly-ai-skills`, the directory name produced by installs made during a 37-hour window in March 2026 when `SKILL.md` carried the repository name in its `name:` field. Those copies work, so reporting them as missing would be a false alarm; `status` labels the path as legacy, and `install` / `update` still write only to `linkly-ai`. ## Connection Modes The CLI supports three connection modes: | Mode | Flags | Auth | How it works | | ---------- | ------------------------------------------- | ------------------------------------ | ----------------------------------------------- | | **Local** | _(default)_ | None (localhost) | Reads `~/.linkly/port`, connects to `127.0.0.1` | | **LAN** | `--lan`, or `--endpoint --token ` | LAN token via `auth set-key --lan` | Direct connection to a LAN device | | **Remote** | `--remote` | API Key via `auth login` / `set-key` | Connects via `https://mcp.linkly.ai` tunnel | > **Note:** Without `--lan` or `--remote` the CLI only talks to the desktop on this machine. `--lan`, `--remote` and `--endpoint` are mutually exclusive; `--endpoint` and `--token` are required together and ignore the saved LAN connection. ### Remote mode setup ```bash # Sign in through the browser: prints a link and a confirmation code, # opens the browser when it can, and saves a new API key once you authorize linkly auth login # Search via remote tunnel linkly search "machine learning" --remote ``` The link works on any device — open it on your phone if the CLI runs on a server. It is valid for 10 minutes; the page shows which account you are authorizing and the code to compare with your terminal. Agents, or anything that cannot wait in the foreground, split the login in two steps. Run both in the same environment and config directory: ```bash linkly auth login --no-wait --json # {"status":"pending","url":…,"user_code":…,"expires_in":600} # … pass url and user_code to the user, wait for them to authorize … linkly auth login --wait --json # {"status":"ok","account":…,"plan":…,"key_preview":…} ``` `--wait` stops after 300 seconds (`--timeout` to change); run it again while the link is still valid. In `--json` mode failures carry a `code`: `timeout`, `expired`, `denied`, `no_pending_login`, `login_in_progress` (use `--wait`, or `--restart` to start over), `already_logged_in` (run `linkly auth logout` first) and `network`. Every message names the command to run next. Prefer to paste a key? Create one in the dashboard and save it instead: ```bash linkly auth set-key lkai_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ``` ### LAN mode setup ```bash # Save the LAN address and token once (both from the desktop app's Agent usage → View MCP connection settings) linkly auth set-key your_lan_token --lan --endpoint http://192.168.1.100:60606 # Search the desktop on that device linkly search "report" --lan # Or pass both explicitly for a one-off call, without saving anything linkly search "report" --endpoint http://192.168.1.100:60606/mcp --token your_lan_token ``` ### Managing saved credentials The remote API key and the LAN connection live side by side in `~/.linkly/credentials.json` (owner-only permissions); saving or removing one never touches the other. ```bash linkly auth status # show both linkly auth logout # remove the remote API key (same as --remote) linkly auth logout --lan # remove the LAN connection ``` `logout` also revokes a key that `auth login` issued. A key saved with `set-key` is only removed locally, since it may be in use elsewhere — revoke it in the dashboard if needed. Set `LINKLY_API_KEY` to use a key without saving it, for example in a container or in an MCP client's `env` block. It takes precedence over the saved key for every `--remote` command. Set `LINKLY_CONFIG_DIR` to keep credentials (and a login waiting for approval) somewhere other than `~/.linkly` — for example one directory per user when an agent serves several people from the same system account. Each directory holds one account. Discovery of the local desktop app (`~/.linkly/port`) is not affected. ```bash LINKLY_CONFIG_DIR=~/.linkly-alice linkly auth login --no-wait --json LINKLY_CONFIG_DIR=~/.linkly-alice linkly search "notes" --remote ``` ## Options Connection options (`--lan`, `--endpoint`, `--token`, `--remote`) are available on `search`, `find-paths`, `analyze`, `explore`, `grep`, `outline`, `read`, `list`, `note-save`, `status`, `doctor`, and `list-libraries` commands. `mcp` accepts only `--remote`. `--json` and `--client` are available on all commands. ### Naming yourself with `--client` Desktop keeps a local access log of every MCP call so the user can see which AI applications read their documents. `--client ` is how a call gets a name there; without it the entry shows only where the call came from (local, LAN, remote). **If you are an agent driving this CLI, always pass it**: ```bash linkly search "budget report" --client claude-code ``` `linkly mcp` does not need it: the bridge uses the name the connecting application gives itself. Pass `--client` there only to override that name (`linkly mcp --client cursor`). It is a label, not a credential: it grants nothing and is never checked against anything, which is also why it cannot be made required — a person typing commands in a terminal should not have to name themselves. Printable ASCII, up to 64 characters; anything else is ignored rather than rejected, so a bad value never fails a call. | Flag | Scope | Description | | ------------------ | ------ | --------------------------------------------------------------------------------------------------------------------------------------------- | | `--lan` | LAN | Connect to the LAN desktop saved by `auth set-key --lan` (conflicts with `--remote`, `--endpoint`) | | `--endpoint ` | LAN | Connect to a specific MCP endpoint (e.g. `http://192.168.1.100:60606/mcp`), requires `--token` | | `--token ` | LAN | Bearer token for LAN authentication (required with `--endpoint`, conflicts with `--remote`) | | `--remote` | Remote | Connect via `https://mcp.linkly.ai` tunnel (conflicts with `--endpoint`, requires `auth login` or `auth set-key`) | | `--json` | Global | One JSON object per result, errors included (for programs that parse the output) | | `--exit-code` | Global | Exit 0 = results, 1 = nothing matched (search, find-paths, grep, list), 2 = failed | | `--client ` | Global | Name the calling application, e.g. `--client claude-code`. Agents should always pass it; `linkly mcp` names its connecting application itself | | `-V, --version` | Global | Print version | | `-h, --help` | Global | Print help | ## Examples ```bash # Local search (default, requires desktop app running) linkly search "budget report" # Search across LAN (after `linkly auth set-key --lan --endpoint `) linkly search "budget report" --lan # Search via remote tunnel linkly search "TODO" --remote # JSON output for scripting linkly search "TODO" --json | jq '.content' # Pipe document content linkly read abc123 --limit 50 | head -20 ``` ## Community - [Documentation](https://linkly.ai/docs) — guides, integrations, and troubleshooting - [Community](https://linkly.ai/docs/en/community) — every official channel in one place - [GitHub Issues](https://github.com/LinklyAI/linkly-ai-cli/issues) — bugs and feature requests - [YouTube](https://www.youtube.com/@LinklyAI) · [X](https://x.com/linkly_ai) ## License Apache-2.0