@fload-ai/mcp 0.12.0 → 0.12.2
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/README.md +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +37 -10
- package/dist/api-client.js.map +2 -2
- package/dist/bin.js +41 -11
- package/dist/bin.js.map +3 -3
- package/dist/index.js +41 -11
- package/dist/index.js.map +3 -3
- package/dist/public-errors.d.ts +2 -0
- package/dist/public-errors.d.ts.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +20 -19
package/dist/index.js
CHANGED
|
@@ -20,8 +20,37 @@ function publicMcpErrorMessage(message, fallbackMessage = "Fload could not compl
|
|
|
20
20
|
}
|
|
21
21
|
return normalized;
|
|
22
22
|
}
|
|
23
|
+
var SCOPE_PATTERN = /^(read|write):[a-z]{2,20}$/;
|
|
24
|
+
function insufficientScopeOf(status, wwwAuthenticate, body) {
|
|
25
|
+
if (status !== 403) return null;
|
|
26
|
+
const fromHeader = wwwAuthenticate?.includes("insufficient_scope") ? /scope="([^"]*)"/.exec(wwwAuthenticate)?.[1] : void 0;
|
|
27
|
+
const record = body && typeof body === "object" ? body : {};
|
|
28
|
+
if (fromHeader === void 0 && record.error !== "insufficient_scope") {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const scope = fromHeader ?? (typeof record.scope === "string" ? record.scope : "");
|
|
32
|
+
return SCOPE_PATTERN.test(scope) ? scope : "";
|
|
33
|
+
}
|
|
34
|
+
function insufficientScopeMessage(scope) {
|
|
35
|
+
const permission = scope ? `the ${scope} permission` : "the permission this needs";
|
|
36
|
+
return `This API key does not have ${permission}. Create a key that includes it in Fload: Settings \u2192 API keys.`;
|
|
37
|
+
}
|
|
23
38
|
|
|
24
39
|
// src/api-client.ts
|
|
40
|
+
function refusalError(response, error) {
|
|
41
|
+
const scope = insufficientScopeOf(
|
|
42
|
+
response.status,
|
|
43
|
+
response.headers.get("www-authenticate"),
|
|
44
|
+
error
|
|
45
|
+
);
|
|
46
|
+
if (scope !== null) return new Error(insufficientScopeMessage(scope));
|
|
47
|
+
return new Error(
|
|
48
|
+
publicMcpErrorMessage(
|
|
49
|
+
error.publicMessage || error.message || response.statusText,
|
|
50
|
+
response.status >= 500 ? "Fload could not complete the request. Please try again." : "Fload rejected the request. Please check access and try again."
|
|
51
|
+
)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
25
54
|
var FloadApiClient = class {
|
|
26
55
|
constructor(baseUrl, apiKey) {
|
|
27
56
|
this.baseUrl = baseUrl;
|
|
@@ -42,11 +71,7 @@ var FloadApiClient = class {
|
|
|
42
71
|
});
|
|
43
72
|
if (!response.ok) {
|
|
44
73
|
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
45
|
-
|
|
46
|
-
error.publicMessage || error.message || response.statusText,
|
|
47
|
-
response.status >= 500 ? "Fload could not complete the request. Please try again." : "Fload rejected the request. Please check access and try again."
|
|
48
|
-
);
|
|
49
|
-
throw new Error(safeError);
|
|
74
|
+
throw refusalError(response, error);
|
|
50
75
|
}
|
|
51
76
|
return response.json();
|
|
52
77
|
}
|
|
@@ -82,6 +107,12 @@ var FloadApiClient = class {
|
|
|
82
107
|
body: body ? JSON.stringify(body) : void 0
|
|
83
108
|
});
|
|
84
109
|
const parsed = await response.json().catch(() => null);
|
|
110
|
+
const scope = insufficientScopeOf(
|
|
111
|
+
response.status,
|
|
112
|
+
response.headers.get("www-authenticate"),
|
|
113
|
+
parsed
|
|
114
|
+
);
|
|
115
|
+
if (scope !== null) throw new Error(insufficientScopeMessage(scope));
|
|
85
116
|
return { ok: response.ok, status: response.status, body: parsed };
|
|
86
117
|
}
|
|
87
118
|
async patch(path, body) {
|
|
@@ -110,11 +141,7 @@ var FloadApiClient = class {
|
|
|
110
141
|
});
|
|
111
142
|
if (!response.ok) {
|
|
112
143
|
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
113
|
-
|
|
114
|
-
error.publicMessage || error.message || response.statusText,
|
|
115
|
-
response.status >= 500 ? "Fload could not complete the request. Please try again." : "Fload rejected the request. Please check access and try again."
|
|
116
|
-
);
|
|
117
|
-
throw new Error(safeError);
|
|
144
|
+
throw refusalError(response, error);
|
|
118
145
|
}
|
|
119
146
|
return response.text();
|
|
120
147
|
}
|
|
@@ -2393,12 +2420,15 @@ function registerTools(server, client, options = {}) {
|
|
|
2393
2420
|
);
|
|
2394
2421
|
}
|
|
2395
2422
|
|
|
2423
|
+
// src/version.ts
|
|
2424
|
+
var FLOAD_MCP_VERSION = "0.12.2";
|
|
2425
|
+
|
|
2396
2426
|
// src/server.ts
|
|
2397
2427
|
async function createMcpServer(_config, client) {
|
|
2398
2428
|
console.error("[Fload MCP] Server initializing...");
|
|
2399
2429
|
const server = new McpServer({
|
|
2400
2430
|
name: "fload",
|
|
2401
|
-
version:
|
|
2431
|
+
version: FLOAD_MCP_VERSION
|
|
2402
2432
|
});
|
|
2403
2433
|
registerTools(server, client);
|
|
2404
2434
|
console.error("[Fload MCP] Registered tools");
|