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

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 (2) hide show
  1. package/index.js +27 -8
  2. package/package.json +1 -1
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@rui.branco/1password-mcp",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
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.",
5
5
  "main": "index.js",
6
6
  "bin": {