# Pack Mode over MCP (`lp mcp`)

`logicpacks` is the same program as `lp`. Configs use it because `lp` is also the printer command on macOS and Linux.

`lp mcp` is an MCP server. Any MCP client (Claude Code, Codex, OpenCode, Cursor, Gemini CLI) can then find, run, check,
push and share packs. Keys stay on your machine with LogicPacks keys: the model sees key NAMES, masked hints and `lp_sealed_*` placeholders, never values.

## Add it to your client

| client | command |
|---|---|
| Claude Code | `claude mcp add --scope user logicpacks -- ~/.logicpacks/bin/logicpacks mcp` (or `logicpacks mcp install claude --apply`), or the plugin in `integrations/claude-plugin` (MCP server + Pack Mode skill) |
| Codex | `logicpacks mcp install codex --apply` (adds `[mcp_servers.logicpacks]` to `~/.codex/config.toml`) |
| OpenCode | `logicpacks mcp install opencode --apply` (`mcp.logicpacks` in `~/.config/opencode/opencode.json`) |
| Cursor | `logicpacks mcp install cursor --apply` (`~/.cursor/mcp.json`) |
| Gemini CLI | `logicpacks mcp install gemini --apply` (`~/.gemini/settings.json`) |

Without `--apply`, the command only prints the config. With `--apply`, lp first copies the file to `<file>.lp-backup` and then adds
only the `logicpacks` entry. `lp mcp config <client>` prints the raw snippet. To undo: remove the `logicpacks` entry, or
`claude mcp remove --scope user logicpacks`.

Codex asks for approval before tools that aren't read-only. For non-interactive `codex exec`, allow them per tool:
`-c mcp_servers.logicpacks.tools.run_pack.approval_mode="approve"`. Read-only tools never need it.

## Tools

| tool | read-only | what it does |
|---|---|---|
| `search_packs(query, category?)` | yes | plain-words search over your packs, shared packs and public packs; returns refs, level, keys needed |
| `get_pack(pack)` | yes | spec, routes (which one will run here), key readiness, code preview, `how_to_run` |
| `run_pack(pack, inputs?, route?, command?)` | no | runs the pack's route (free first) via `lp run`; `inputs` become `LP_IN_<NAME>` |
| `check_pack(pack, route?, inputs?)` | no | runs the outcome checks, records the result (L1/L2) |
| `push_pack(path, public?, space?)` | no | `lp push`: scaffold if needed, secret scan, checks, upload (private by default) |
| `share(thing, user, role?, ttl?)` | no | invite to a pack, space or key; nothing is shared until accepted |
| `list_invites()` | yes | incoming and sent invites |
| `accept_invite(id)` / `reject_invite(id)` | no | answer an invite |
| `review_pack(pack@version, verdict, notes, evidence?)` | no | signed human review (L3) in the user's name |
| `my_packs()` | yes | own and shared packs with counts |
| `list_keys()` | yes | key names, masked hints, which packs can use them |
| `ledger_list()` | yes | your ledgers: main, shared with you, core |
| `note_search(query, ledger?, category?)` | yes | search notes across your ledgers |
| `note_read(note, ledger?)` | yes | one note with its comment thread |
| `note_add(title, body?, ledger?, category?, tags?)` | no | add a note (default: main ledger, category Inbox); secrets refused |
| `note_dump(text, ledger?)` | no | append raw text/logs to today's inbox note |
| `comment_add(target, text, kind?, ledger?, closes?)` | no | comment / issue / fix / run on a note or a pack (`space/pack@ver`) |
| `inbox(all?)` | yes | new comments, issues, fixes, notes and invites |
| `ledger_share(ledger, user, role?)` | no | invite @someone to a ledger (they accept first) |

Tools that aren't read-only say what they do in their description (for example "RUNS CODE ON THIS COMPUTER") and return a
`did` line. Every call is logged to `~/.logicpacks/mcp.log` (tool and arguments; anything that looks like a secret is withheld).

## Transports

- stdio (default): `lp mcp`.
- Streamable HTTP: `lp mcp --http [--port 7490] [--host 127.0.0.1] [--token-file FILE]`; send JSON-RPC as `POST /mcp`,
  health check at `GET /health`. With a token, every request needs `Authorization: Bearer <token>`. lp refuses to listen on
  anything other than localhost without a token.
- Remote connector: `https://mcp.logicpacks.io/mcp` (below).

## Remote connector (ChatGPT, Claude.ai, any MCP client with OAuth)

Add `https://mcp.logicpacks.io/mcp` as a custom connector (Claude.ai: Settings > Connectors > Add custom connector;
ChatGPT: Settings > Connectors > Create, developer mode). The client discovers sign-in by itself:

- `POST /mcp` without a token answers 401 with `WWW-Authenticate: Bearer resource_metadata=".../.well-known/oauth-protected-resource"`.
- `/.well-known/oauth-protected-resource` (RFC 9728) names the authorization server; `/.well-known/oauth-authorization-server`
  (RFC 8414) lists `/authorize`, `/token`, `/register`, `/revoke`.
- Dynamic client registration (RFC 7591), authorization code with PKCE S256 (required), `resource` binding (RFC 8707),
  rotating refresh tokens (reuse revokes the whole sign-in), revocation (RFC 7009). Access tokens last 1 hour.

Sign-in page: type your @handle. A new handle is created for you right away. For a handle that already exists, the page
shows a code; approve it on a computer where you use LogicPacks: `logicpacks device approve <code>`. The page continues by
itself. Nobody can sign in as you by typing your handle.

Remote tools: `search_packs`, `get_pack`, `my_packs`, `list_invites`, `accept_invite`, `reject_invite`, `share`, and the
ledger tools (`ledger_list`, `note_search`, `note_read`, `note_add`, `note_dump`, `comment_add`, `inbox`, `ledger_share`) for
shared and synced ledgers (a local-only `main` stays on your computer; notes are signed `agent:<connector>@<you>`). Packs
are not run on the server: keys stay on your computer. `get_pack` returns `how_to_run` (install `logicpacks`, then run).
To let an agent run packs, use the local `lp mcp` above.

The server keeps a per-connector signing key, encrypted at rest; tokens are stored only as SHA-256 hashes. Arguments that
look like a secret are refused.


---

Canonical URL: https://logicpacks.io/mcp.md

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](/llms.txt). Plain facts: [/about.md](/about.md). Safety: [/safety.md](/safety.md).
