@hapticpaper/mcp-server 1.0.19 → 1.0.21

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.
@@ -132,4 +132,9 @@ export class TokenManager {
132
132
  return null;
133
133
  }
134
134
  }
135
+ async clearTokens() {
136
+ if (fs.existsSync(this.tokenPath)) {
137
+ await fs.promises.unlink(this.tokenPath);
138
+ }
139
+ }
135
140
  }
@@ -20,6 +20,24 @@ export class HapticPaperClient {
20
20
  }
21
21
  return config;
22
22
  });
23
+ // Response interceptor to handle auth errors
24
+ this.client.interceptors.response.use((response) => response, async (error) => {
25
+ const originalRequest = error.config;
26
+ if (error.response?.status === 401 && !originalRequest._retry && config.onAuthError) {
27
+ originalRequest._retry = true;
28
+ try {
29
+ const newToken = await config.onAuthError();
30
+ if (typeof newToken === 'string') {
31
+ originalRequest.headers.Authorization = `Bearer ${newToken}`;
32
+ return this.client(originalRequest);
33
+ }
34
+ }
35
+ catch (authError) {
36
+ return Promise.reject(authError);
37
+ }
38
+ }
39
+ return Promise.reject(error);
40
+ });
23
41
  }
24
42
  async authHeaders(accessToken) {
25
43
  if (accessToken) {
package/dist/index.js CHANGED
@@ -145,6 +145,11 @@ ${widgetJs}
145
145
  }
146
146
  // 3. No token - auto-trigger OAuth
147
147
  return runOAuthFlow();
148
+ },
149
+ onAuthError: transportType === 'http' ? undefined : async () => {
150
+ console.error('Authentication failed (401). Clearing tokens and re-authenticating...');
151
+ await tokenManager.clearTokens();
152
+ return runOAuthFlow();
148
153
  }
149
154
  });
150
155
  // Transport
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hapticpaper/mcp-server",
3
3
  "mcpName": "com.hapticpaper/mcp",
4
- "version": "1.0.19",
4
+ "version": "1.0.21",
5
5
  "description": "Official MCP Server for Haptic Paper - Connect your account to create human tasks from agentic pipelines.",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
package/server.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "subfolder": "packages/mcp-server"
26
26
  },
27
27
  "websiteUrl": "https://hapticpaper.com/developer",
28
- "version": "1.0.19",
28
+ "version": "1.0.21",
29
29
  "remotes": [
30
30
  {
31
31
  "type": "streamable-http",
@@ -37,7 +37,7 @@
37
37
  "registryType": "npm",
38
38
  "registryBaseUrl": "https://registry.npmjs.org",
39
39
  "identifier": "@hapticpaper/mcp-server",
40
- "version": "1.0.19",
40
+ "version": "1.0.21",
41
41
  "transport": {
42
42
  "type": "stdio"
43
43
  },