@magnetlab/mcp 0.1.2 → 0.1.3

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/dist/client.js +19 -6
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // packages/mcp/src/client.ts
2
- const DEFAULT_BASE_URL = 'https://magnetlab.app/api';
2
+ const DEFAULT_BASE_URL = 'https://www.magnetlab.app/api';
3
3
  export class MagnetLabClient {
4
4
  apiKey;
5
5
  baseUrl;
@@ -13,11 +13,24 @@ export class MagnetLabClient {
13
13
  Authorization: `Bearer ${this.apiKey}`,
14
14
  'Content-Type': 'application/json',
15
15
  };
16
- const response = await fetch(url, {
16
+ let response = await fetch(url, {
17
17
  method,
18
18
  headers,
19
19
  body: body ? JSON.stringify(body) : undefined,
20
+ redirect: 'manual',
20
21
  });
22
+ // Follow redirects manually to preserve the Authorization header
23
+ if (response.status >= 300 && response.status < 400) {
24
+ const location = response.headers.get('location');
25
+ if (location) {
26
+ response = await fetch(location, {
27
+ method,
28
+ headers,
29
+ body: body ? JSON.stringify(body) : undefined,
30
+ redirect: 'manual',
31
+ });
32
+ }
33
+ }
21
34
  if (!response.ok) {
22
35
  const error = await response.json().catch(() => ({ error: 'Unknown error' }));
23
36
  throw new Error(error.error || `Request failed: ${response.status}`);
@@ -43,7 +56,7 @@ export class MagnetLabClient {
43
56
  return this.request('GET', `/lead-magnet?${searchParams}`);
44
57
  }
45
58
  async getLeadMagnet(id) {
46
- return this.request('GET', `/external/lead-magnets/${id}`);
59
+ return this.request('GET', `/lead-magnet/${id}`);
47
60
  }
48
61
  async createLeadMagnet(params) {
49
62
  return this.request('POST', `/lead-magnet`, params);
@@ -55,13 +68,13 @@ export class MagnetLabClient {
55
68
  return this.request('POST', `/lead-magnet/ideate`, params);
56
69
  }
57
70
  async extractContent(leadMagnetId, params) {
58
- return this.request('POST', `/external/lead-magnets/${leadMagnetId}/extract`, params);
71
+ return this.request('POST', `/lead-magnet/extract`, params);
59
72
  }
60
73
  async generateContent(leadMagnetId, params) {
61
- return this.request('POST', `/external/lead-magnets/${leadMagnetId}/generate`, params);
74
+ return this.request('POST', `/lead-magnet/generate`, params);
62
75
  }
63
76
  async writeLinkedInPosts(leadMagnetId, params) {
64
- return this.request('POST', `/external/lead-magnets/${leadMagnetId}/write-posts`, params);
77
+ return this.request('POST', `/lead-magnet/write-post`, params);
65
78
  }
66
79
  async polishLeadMagnetContent(leadMagnetId) {
67
80
  return this.request('POST', `/lead-magnet/${leadMagnetId}/polish`, {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magnetlab/mcp",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "MCP server for MagnetLab - control your lead magnets, funnels, content pipeline, and analytics from Claude Code",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",