burn-mcp-server 2.0.5 → 2.0.7

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.
@@ -0,0 +1,20 @@
1
+ // Vercel Edge handler — pre-bundled by esbuild into api/mcp.mjs
2
+
3
+ import { handleMcpRequest } from './http.js'
4
+
5
+ export const config = { runtime: 'edge' }
6
+
7
+ export default async function handler(req: Request): Promise<Response> {
8
+ try {
9
+ return await handleMcpRequest(req)
10
+ } catch (e: any) {
11
+ return new Response(JSON.stringify({
12
+ error: 'Handler threw',
13
+ message: String(e?.message || e),
14
+ stack: String(e?.stack || '').slice(0, 2000),
15
+ }), {
16
+ status: 500,
17
+ headers: { 'content-type': 'application/json' },
18
+ })
19
+ }
20
+ }
@@ -0,0 +1,76 @@
1
+ // Vercel Node runtime handler — uses StreamableHTTPServerTransport (non-Web variant).
2
+ // Pre-bundled by esbuild into api/mcp.js (Vercel detects .js as Node function).
3
+
4
+ import type { IncomingMessage, ServerResponse } from 'node:http'
5
+ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js'
6
+ import { createClient } from '@supabase/supabase-js'
7
+ import { getOrExchangeSession } from './lib/auth.js'
8
+ import { createBurnServer } from './setup.js'
9
+
10
+ const SUPABASE_URL = process.env.BURN_SUPABASE_URL || 'https://juqtxylquemiuvvmgbej.supabase.co'
11
+ const SUPABASE_ANON_KEY = process.env.BURN_SUPABASE_ANON_KEY || 'sb_publishable_reVgmmCC6ndIo6jFRMM2LQ_wujj5FrO'
12
+
13
+ export default async function handler(req: IncomingMessage, res: ServerResponse): Promise<void> {
14
+ try {
15
+ // --- Auth ---
16
+ const authHeader = (req.headers.authorization || req.headers.Authorization || '') as string
17
+ const m = authHeader.match(/^Bearer\s+(.+)$/i)
18
+ const token = m?.[1]?.trim()
19
+
20
+ if (!token) {
21
+ res.statusCode = 401
22
+ res.setHeader('content-type', 'application/json')
23
+ res.end(JSON.stringify({
24
+ error: 'Missing Authorization header',
25
+ hint: 'Add `Authorization: Bearer <BURN_MCP_TOKEN>` — get yours at https://burn451.cloud → Settings → MCP Server.',
26
+ }))
27
+ return
28
+ }
29
+
30
+ // --- Exchange token → Supabase session (in-memory cache per token) ---
31
+ let session
32
+ try {
33
+ session = await getOrExchangeSession(token)
34
+ } catch (e: any) {
35
+ res.statusCode = 401
36
+ res.setHeader('content-type', 'application/json')
37
+ res.end(JSON.stringify({ error: 'Invalid or expired Burn MCP token', detail: String(e?.message || e) }))
38
+ return
39
+ }
40
+
41
+ // --- Per-request Supabase client with JWT in headers ---
42
+ const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
43
+ auth: { persistSession: false, autoRefreshToken: false, detectSessionInUrl: false },
44
+ global: { headers: { Authorization: `Bearer ${session.access_token}` } },
45
+ })
46
+
47
+ const server = createBurnServer(supabase, { rateLimitPerMin: 60 })
48
+
49
+ // --- Stateless transport, JSON response mode ---
50
+ const transport = new StreamableHTTPServerTransport({
51
+ sessionIdGenerator: undefined,
52
+ enableJsonResponse: true,
53
+ })
54
+
55
+ await server.connect(transport)
56
+
57
+ // Read body — Vercel Node already parses JSON for us at req.body, but let's be safe
58
+ let parsedBody: unknown
59
+ if ((req as any).body !== undefined) {
60
+ parsedBody = (req as any).body
61
+ } else {
62
+ const chunks: Buffer[] = []
63
+ for await (const c of req) chunks.push(c as Buffer)
64
+ const raw = Buffer.concat(chunks).toString('utf8')
65
+ try { parsedBody = raw ? JSON.parse(raw) : undefined } catch { parsedBody = undefined }
66
+ }
67
+
68
+ await transport.handleRequest(req as any, res, parsedBody)
69
+ } catch (e: any) {
70
+ if (!res.headersSent) {
71
+ res.statusCode = 500
72
+ res.setHeader('content-type', 'application/json')
73
+ res.end(JSON.stringify({ error: 'Handler threw', message: String(e?.message || e), stack: String(e?.stack || '').slice(0, 2000) }))
74
+ }
75
+ }
76
+ }
package/tsconfig.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "commonjs",
5
- "lib": ["ES2020"],
3
+ "target": "ES2022",
4
+ "module": "ES2022",
5
+ "moduleResolution": "node",
6
+ "lib": ["ES2022"],
6
7
  "outDir": "./dist",
7
8
  "rootDir": "./src",
8
- "strict": true,
9
+ "strict": false,
9
10
  "esModuleInterop": true,
10
11
  "skipLibCheck": true,
11
- "resolveJsonModule": true
12
+ "resolveJsonModule": true,
13
+ "noEmit": true,
14
+ "allowJs": true
12
15
  },
13
- "include": ["src/**/*"]
16
+ "include": ["src/lib/**/*", "src/index.ts", "src/http.ts", "src/http-dev.ts"],
17
+ "exclude": ["src/setup.ts", "api/**/*", "dist/**/*", "node_modules/**/*"]
14
18
  }
package/vercel.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://openapi.vercel.sh/vercel.json",
3
+ "buildCommand": "npm run build:vercel",
4
+ "outputDirectory": "public",
5
+ "rewrites": [
6
+ { "source": "/mcp", "destination": "/api/mcp" },
7
+ { "source": "/mcp/(.*)", "destination": "/api/mcp" }
8
+ ]
9
+ }
@@ -1 +0,0 @@
1
- ghu_O9YKcVdRYkRh7toV5NSHdMPiXcLm022eK2rf
@@ -1 +0,0 @@
1
- {"token":"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJtY3AtcmVnaXN0cnkiLCJleHAiOjE3NzU2MjUxNTcsIm5iZiI6MTc3NTYyNDg1NywiaWF0IjoxNzc1NjI0ODU3LCJhdXRoX21ldGhvZCI6ImdpdGh1Yi1hdCIsImF1dGhfbWV0aG9kX3N1YiI6IkZpc2hlcjUyMSIsInBlcm1pc3Npb25zIjpbeyJhY3Rpb24iOiJwdWJsaXNoIiwicmVzb3VyY2UiOiJpby5naXRodWIuRmlzaGVyNTIxLyoifV19.xHyojzKsFpwXquzD5L_RWurjUH-q6LlNM0Tf75AsN5QkOsDidVszBkb2vXGxJGXfwvUlgi2AA47sjujdP5tNCA","expires_at":1775625157}
package/smithery.yaml DELETED
@@ -1,17 +0,0 @@
1
- # Smithery configuration file: https://smithery.ai/docs/config#smitheryyaml
2
-
3
- startCommand:
4
- type: stdio
5
-
6
- configSchema:
7
- type: object
8
- required:
9
- - burnMcpToken
10
- properties:
11
- burnMcpToken:
12
- type: string
13
- description: Long-lived MCP access token from Burn App Settings page.
14
-
15
- commandFunction:
16
- |-
17
- (config) => ({ command: 'npx', args: ['-y', 'burn-mcp-server'], env: { BURN_MCP_TOKEN: config.burnMcpToken } })