@rui.branco/1password-mcp 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +28 -3
  2. package/index.js +27 -8
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for [1Password](https://1password.com/) that runs **entirely locally** — no external services, no telemetry, no leaks. Uses the official [`@1password/sdk`](https://www.npmjs.com/package/@1password/sdk) with a 1Password Service Account token.
4
4
 
5
- Built to mirror the multi-instance pattern of [jira-mcp](https://github.com/rui-branco/jira-mcp) so you can point the same Claude Code session at multiple 1Password accounts (e.g. `work` and `personal`).
5
+ Works with any MCP-compatible AI client — Claude Code, Codex CLI, Google's Antigravity (Gemini), Cursor, Windsurf, Zed, and others. Built to mirror the multi-instance pattern of [jira-mcp](https://github.com/rui-branco/jira-mcp) so you can point the same session at multiple 1Password accounts (e.g. `work` and `personal`).
6
6
 
7
7
  ## Features
8
8
 
@@ -16,16 +16,41 @@ Built to mirror the multi-instance pattern of [jira-mcp](https://github.com/rui-
16
16
  ### Prerequisites
17
17
 
18
18
  - Node.js 18+
19
+ - An MCP-compatible AI client (see [Step 1](#step-1-register-with-your-mcp-client) below)
19
20
  - Either:
20
21
  - **The 1Password 8 desktop app** (recommended — no admin permissions needed, and you get access to all vaults you can already see), or
21
22
  - A 1Password **service account** token (needs admin to provision, scoped to shared vaults only — good for CI/headless use)
22
23
 
23
- ### Step 1: Install and register the MCP
24
+ ### Step 1: Register with your MCP client
25
+
26
+ Pick the snippet for your client. All of them launch the server over stdio.
27
+
28
+ **Claude Code:**
24
29
 
25
30
  ```bash
26
31
  claude mcp add --scope user --transport stdio 1password -- npx -y @rui.branco/1password-mcp
27
32
  ```
28
33
 
34
+ **Codex CLI:** add to `~/.codex/config.toml`:
35
+
36
+ ```toml
37
+ [mcp_servers.1password]
38
+ command = "npx"
39
+ args = ["-y", "@rui.branco/1password-mcp"]
40
+ ```
41
+
42
+ **Google Antigravity / Gemini CLI:** add to `~/.gemini/settings.json`:
43
+
44
+ ```json
45
+ {
46
+ "mcpServers": {
47
+ "1password": { "command": "npx", "args": ["-y", "@rui.branco/1password-mcp"] }
48
+ }
49
+ }
50
+ ```
51
+
52
+ **Cursor, Windsurf, Zed, Cline, Continue, etc.:** add the same `command`/`args` pair to whatever JSON config that client uses for MCP servers (the exact path varies, but the shape is standard across clients).
53
+
29
54
  ### Step 2: Run setup
30
55
 
31
56
  ```bash
@@ -53,7 +78,7 @@ When the wizard asks for "Account name", open the 1Password 8 desktop app and cl
53
78
 
54
79
  ### Step 4: Reconnect
55
80
 
56
- Run `/mcp` in Claude Code to reconnect the 1password server and pick up the new config.
81
+ Restart your AI client and check its MCP status (e.g. `/mcp` in Claude Code, `mcp` in Codex CLI, or the equivalent panel in your client) to reconnect the 1password server and pick up the new config.
57
82
 
58
83
  ## Tools
59
84
 
package/index.js CHANGED
@@ -175,6 +175,17 @@ function invalidateClient(name) {
175
175
  clientCache.delete(name);
176
176
  }
177
177
 
178
+ /**
179
+ * Detect errors that indicate the IPC / desktop-app session is dead so the
180
+ * cached SDK client can be discarded and a fresh one created on retry.
181
+ */
182
+ function isSessionError(e) {
183
+ if (e instanceof sdk.DesktopSessionExpiredError) return true;
184
+ // Belt-and-suspenders: catch IPC / auth wording from the native layer even
185
+ // when the SDK wraps it in a generic Error.
186
+ return /IPC|session.expired|desktop.auth|socket.closed/i.test(e.message);
187
+ }
188
+
178
189
  // ============================================================================
179
190
  // Helpers — vault/item resolution, redaction, formatting
180
191
  // ============================================================================
@@ -1217,14 +1228,22 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1217
1228
  isError: true,
1218
1229
  };
1219
1230
  }
1220
- try {
1221
- const result = await handler(args || {});
1222
- return { content: [{ type: "text", text: String(result) }] };
1223
- } catch (e) {
1224
- return {
1225
- content: [{ type: "text", text: `Error: ${e.message}` }],
1226
- isError: true,
1227
- };
1231
+ for (let attempt = 0; attempt < 2; attempt++) {
1232
+ try {
1233
+ const result = await handler(args || {});
1234
+ return { content: [{ type: "text", text: String(result) }] };
1235
+ } catch (e) {
1236
+ if (attempt === 0 && isSessionError(e)) {
1237
+ // Stale IPC connection — purge cached clients and retry once so the
1238
+ // next getClient() call creates a fresh session.
1239
+ clientCache.clear();
1240
+ continue;
1241
+ }
1242
+ return {
1243
+ content: [{ type: "text", text: `Error: ${e.message}` }],
1244
+ isError: true,
1245
+ };
1246
+ }
1228
1247
  }
1229
1248
  });
1230
1249
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rui.branco/1password-mcp",
3
- "version": "0.1.5",
4
- "description": "1Password MCP server for Claude Code - list vaults and items, get secrets, generate passwords, manage items via service accounts. Multi-instance like jira-mcp.",
3
+ "version": "0.1.7",
4
+ "description": "1Password MCP server for any MCP-compatible AI client (Claude Code, Codex, Antigravity, Cursor, etc.) - list vaults and items, get secrets, generate passwords, manage items via service accounts. Multi-instance like jira-mcp.",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "1password-mcp": "./index.js"