@abraca/mcp 1.1.2 → 1.3.1

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.
package/dist/index.d.ts CHANGED
@@ -8731,6 +8731,7 @@ declare class AbracadabraMCPServer {
8731
8731
  private _statusClearTimer;
8732
8732
  private _typingInterval;
8733
8733
  private _lastChatChannel;
8734
+ private _signFn;
8734
8735
  constructor(config: MCPServerConfig);
8735
8736
  get agentName(): string;
8736
8737
  get agentColor(): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abraca/mcp",
3
- "version": "1.1.2",
3
+ "version": "1.3.1",
4
4
  "description": "MCP server for Abracadabra — AI agent collaboration on CRDT documents",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/server.ts CHANGED
@@ -51,6 +51,7 @@ export class AbracadabraMCPServer {
51
51
  private _statusClearTimer: ReturnType<typeof setTimeout> | null = null
52
52
  private _typingInterval: ReturnType<typeof setInterval> | null = null
53
53
  private _lastChatChannel: string | null = null
54
+ private _signFn: ((challenge: string) => Promise<string>) | null = null
54
55
 
55
56
  constructor(config: MCPServerConfig) {
56
57
  this.config = config
@@ -98,6 +99,7 @@ export class AbracadabraMCPServer {
98
99
  const keypair = await loadOrCreateKeypair(this.config.keyFile)
99
100
  this._userId = keypair.publicKeyB64
100
101
  const signFn = (challenge: string) => Promise.resolve(signChallenge(challenge, keypair.privateKey))
102
+ this._signFn = signFn
101
103
 
102
104
  // Step 2: Authenticate via challenge-response (register on first run)
103
105
  try {
@@ -179,6 +181,13 @@ export class AbracadabraMCPServer {
179
181
  return existing
180
182
  }
181
183
 
184
+ // Re-authenticate if JWT has expired (prevents WS auth failures)
185
+ if (!this.client.isTokenValid() && this._signFn && this._userId) {
186
+ console.error('[abracadabra-mcp] JWT expired, re-authenticating...')
187
+ await this.client.loginWithKey(this._userId, this._signFn)
188
+ console.error('[abracadabra-mcp] Re-authenticated successfully')
189
+ }
190
+
182
191
  const doc = new Y.Doc({ guid: docId })
183
192
  const provider = new AbracadabraProvider({
184
193
  name: docId,
@@ -256,6 +265,13 @@ export class AbracadabraMCPServer {
256
265
  throw new Error('Not connected. Call connect() first.')
257
266
  }
258
267
 
268
+ // Re-authenticate if JWT has expired (prevents child WS auth failures)
269
+ if (!this.client.isTokenValid() && this._signFn && this._userId) {
270
+ console.error('[abracadabra-mcp] JWT expired, re-authenticating...')
271
+ await this.client.loginWithKey(this._userId, this._signFn)
272
+ console.error('[abracadabra-mcp] Re-authenticated successfully')
273
+ }
274
+
259
275
  const childProvider = await activeProvider.loadChild(docId)
260
276
  await waitForSync(childProvider)
261
277