sublime-mcp 1.8.5 → 1.8.6
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/http.js +11 -2
- package/package.json +1 -1
package/http.js
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
const port = process.platform === 'win32' ? 9500 : 9501;
|
|
7
7
|
export const BASE = process.env.SUBLIME_MCP_BASE ?? `http://127.0.0.1:${port}`;
|
|
8
8
|
|
|
9
|
+
// Only sent when set -- matches the server's auth_token setting (unset by
|
|
10
|
+
// default on both sides, so this is a no-op unless the user opted in).
|
|
11
|
+
const AUTH_HEADERS = process.env.SUBLIME_MCP_TOKEN
|
|
12
|
+
? { Authorization: `Bearer ${process.env.SUBLIME_MCP_TOKEN}` }
|
|
13
|
+
: {};
|
|
14
|
+
|
|
9
15
|
export const DEFAULT_TIMEOUT_MS = 10_000;
|
|
10
16
|
export const SLOW_TIMEOUT_MS = 120_000;
|
|
11
17
|
export const SLOW_ENDPOINTS = new Set([
|
|
@@ -27,7 +33,10 @@ export async function get(endpoint, params = {}) {
|
|
|
27
33
|
for (const [k, v] of Object.entries(params)) {
|
|
28
34
|
url.searchParams.set(k, String(v));
|
|
29
35
|
}
|
|
30
|
-
const r = await fetch(url, {
|
|
36
|
+
const r = await fetch(url, {
|
|
37
|
+
headers: AUTH_HEADERS,
|
|
38
|
+
signal: AbortSignal.timeout(timeoutMsFor(endpoint)),
|
|
39
|
+
});
|
|
31
40
|
if (!r.ok) throw new Error(`HTTP ${r.status} from ${endpoint}`);
|
|
32
41
|
return r.json();
|
|
33
42
|
}
|
|
@@ -35,7 +44,7 @@ export async function get(endpoint, params = {}) {
|
|
|
35
44
|
export async function post(endpoint, body = {}) {
|
|
36
45
|
const r = await fetch(new URL(endpoint, BASE), {
|
|
37
46
|
method: 'POST',
|
|
38
|
-
headers: { 'Content-Type': 'application/json' },
|
|
47
|
+
headers: { 'Content-Type': 'application/json', ...AUTH_HEADERS },
|
|
39
48
|
body: JSON.stringify(body),
|
|
40
49
|
signal: AbortSignal.timeout(timeoutMsFor(endpoint)),
|
|
41
50
|
});
|
package/package.json
CHANGED