burn-mcp-server 1.1.0 → 1.2.0
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.js +32 -12
- package/package.json +1 -1
- package/src/index.ts +36 -12
package/dist/index.js
CHANGED
|
@@ -10,32 +10,51 @@ const zod_1 = require("zod");
|
|
|
10
10
|
// ---------------------------------------------------------------------------
|
|
11
11
|
const SUPABASE_URL = process.env.BURN_SUPABASE_URL || 'https://juqtxylquemiuvvmgbej.supabase.co';
|
|
12
12
|
const SUPABASE_ANON_KEY = process.env.BURN_SUPABASE_ANON_KEY || 'sb_publishable_reVgmmCC6ndIo6jFRMM2LQ_wujj5FrO';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
// Support both old JWT token (BURN_SUPABASE_TOKEN) and new long-lived MCP token (BURN_MCP_TOKEN)
|
|
14
|
+
const MCP_TOKEN = process.env.BURN_MCP_TOKEN;
|
|
15
|
+
const LEGACY_JWT = process.env.BURN_SUPABASE_TOKEN;
|
|
16
|
+
if (!MCP_TOKEN && !LEGACY_JWT) {
|
|
17
|
+
console.error('Error: BURN_MCP_TOKEN environment variable is required.');
|
|
18
|
+
console.error('Get your token from: Burn App → Settings → MCP Server → Generate Token');
|
|
17
19
|
process.exit(1);
|
|
18
20
|
}
|
|
19
21
|
// ---------------------------------------------------------------------------
|
|
20
|
-
// Supabase client
|
|
22
|
+
// Supabase client — bootstrapped with anon key, session set after auth below
|
|
21
23
|
// ---------------------------------------------------------------------------
|
|
22
24
|
const supabase = (0, supabase_js_1.createClient)(SUPABASE_URL, SUPABASE_ANON_KEY, {
|
|
23
25
|
auth: {
|
|
24
26
|
persistSession: false,
|
|
25
|
-
autoRefreshToken:
|
|
26
|
-
},
|
|
27
|
-
global: {
|
|
28
|
-
headers: {
|
|
29
|
-
Authorization: `Bearer ${SUPABASE_TOKEN}`,
|
|
30
|
-
},
|
|
27
|
+
autoRefreshToken: true,
|
|
31
28
|
},
|
|
29
|
+
...(LEGACY_JWT ? { global: { headers: { Authorization: `Bearer ${LEGACY_JWT}` } } } : {}),
|
|
32
30
|
});
|
|
33
31
|
// ---------------------------------------------------------------------------
|
|
32
|
+
// Auth: exchange MCP token for a real Supabase session (auto-refreshes)
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
async function initAuth() {
|
|
35
|
+
if (LEGACY_JWT)
|
|
36
|
+
return; // legacy mode: JWT already set in headers above
|
|
37
|
+
// Call SECURITY DEFINER function — works with anon key, no JWT needed
|
|
38
|
+
const { data, error } = await supabase.rpc('get_mcp_session', { p_token: MCP_TOKEN });
|
|
39
|
+
if (error || !data || data.length === 0) {
|
|
40
|
+
console.error('Error: Invalid or revoked BURN_MCP_TOKEN.');
|
|
41
|
+
console.error('Generate a new token in Burn App → Settings → MCP Server → Generate Token');
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
const { refresh_token } = data[0];
|
|
45
|
+
const { error: refreshError } = await supabase.auth.refreshSession({ refresh_token });
|
|
46
|
+
if (refreshError) {
|
|
47
|
+
console.error('Error: Failed to refresh session with stored token.', refreshError.message);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
// supabase client now has a valid session and will auto-refresh going forward
|
|
51
|
+
}
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
34
53
|
// MCP Server
|
|
35
54
|
// ---------------------------------------------------------------------------
|
|
36
55
|
const server = new mcp_js_1.McpServer({
|
|
37
56
|
name: 'burn-mcp-server',
|
|
38
|
-
version: '1.
|
|
57
|
+
version: '1.2.0',
|
|
39
58
|
});
|
|
40
59
|
// ---------------------------------------------------------------------------
|
|
41
60
|
// Helper: standard text result
|
|
@@ -498,6 +517,7 @@ server.resource('vault-categories', 'burn://vault/categories', async (uri) => {
|
|
|
498
517
|
// Start
|
|
499
518
|
// ---------------------------------------------------------------------------
|
|
500
519
|
async function main() {
|
|
520
|
+
await initAuth();
|
|
501
521
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
502
522
|
await server.connect(transport);
|
|
503
523
|
console.error('Burn MCP Server running on stdio');
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -11,37 +11,60 @@ import { z } from 'zod'
|
|
|
11
11
|
|
|
12
12
|
const SUPABASE_URL = process.env.BURN_SUPABASE_URL || 'https://juqtxylquemiuvvmgbej.supabase.co'
|
|
13
13
|
const SUPABASE_ANON_KEY = process.env.BURN_SUPABASE_ANON_KEY || 'sb_publishable_reVgmmCC6ndIo6jFRMM2LQ_wujj5FrO'
|
|
14
|
-
const SUPABASE_TOKEN = process.env.BURN_SUPABASE_TOKEN
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
// Support both old JWT token (BURN_SUPABASE_TOKEN) and new long-lived MCP token (BURN_MCP_TOKEN)
|
|
16
|
+
const MCP_TOKEN = process.env.BURN_MCP_TOKEN
|
|
17
|
+
const LEGACY_JWT = process.env.BURN_SUPABASE_TOKEN
|
|
18
|
+
|
|
19
|
+
if (!MCP_TOKEN && !LEGACY_JWT) {
|
|
20
|
+
console.error('Error: BURN_MCP_TOKEN environment variable is required.')
|
|
21
|
+
console.error('Get your token from: Burn App → Settings → MCP Server → Generate Token')
|
|
19
22
|
process.exit(1)
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
// ---------------------------------------------------------------------------
|
|
23
|
-
// Supabase client
|
|
26
|
+
// Supabase client — bootstrapped with anon key, session set after auth below
|
|
24
27
|
// ---------------------------------------------------------------------------
|
|
25
28
|
|
|
26
29
|
const supabase: SupabaseClient = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
|
|
27
30
|
auth: {
|
|
28
31
|
persistSession: false,
|
|
29
|
-
autoRefreshToken:
|
|
30
|
-
},
|
|
31
|
-
global: {
|
|
32
|
-
headers: {
|
|
33
|
-
Authorization: `Bearer ${SUPABASE_TOKEN}`,
|
|
34
|
-
},
|
|
32
|
+
autoRefreshToken: true,
|
|
35
33
|
},
|
|
34
|
+
...(LEGACY_JWT ? { global: { headers: { Authorization: `Bearer ${LEGACY_JWT}` } } } : {}),
|
|
36
35
|
})
|
|
37
36
|
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// Auth: exchange MCP token for a real Supabase session (auto-refreshes)
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
async function initAuth(): Promise<void> {
|
|
42
|
+
if (LEGACY_JWT) return // legacy mode: JWT already set in headers above
|
|
43
|
+
|
|
44
|
+
// Call SECURITY DEFINER function — works with anon key, no JWT needed
|
|
45
|
+
const { data, error } = await supabase.rpc('get_mcp_session', { p_token: MCP_TOKEN })
|
|
46
|
+
if (error || !data || data.length === 0) {
|
|
47
|
+
console.error('Error: Invalid or revoked BURN_MCP_TOKEN.')
|
|
48
|
+
console.error('Generate a new token in Burn App → Settings → MCP Server → Generate Token')
|
|
49
|
+
process.exit(1)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const { refresh_token } = data[0]
|
|
53
|
+
const { error: refreshError } = await supabase.auth.refreshSession({ refresh_token })
|
|
54
|
+
if (refreshError) {
|
|
55
|
+
console.error('Error: Failed to refresh session with stored token.', refreshError.message)
|
|
56
|
+
process.exit(1)
|
|
57
|
+
}
|
|
58
|
+
// supabase client now has a valid session and will auto-refresh going forward
|
|
59
|
+
}
|
|
60
|
+
|
|
38
61
|
// ---------------------------------------------------------------------------
|
|
39
62
|
// MCP Server
|
|
40
63
|
// ---------------------------------------------------------------------------
|
|
41
64
|
|
|
42
65
|
const server = new McpServer({
|
|
43
66
|
name: 'burn-mcp-server',
|
|
44
|
-
version: '1.
|
|
67
|
+
version: '1.2.0',
|
|
45
68
|
})
|
|
46
69
|
|
|
47
70
|
// ---------------------------------------------------------------------------
|
|
@@ -637,6 +660,7 @@ server.resource(
|
|
|
637
660
|
// ---------------------------------------------------------------------------
|
|
638
661
|
|
|
639
662
|
async function main() {
|
|
663
|
+
await initAuth()
|
|
640
664
|
const transport = new StdioServerTransport()
|
|
641
665
|
await server.connect(transport)
|
|
642
666
|
console.error('Burn MCP Server running on stdio')
|