@insforge/mcp 1.2.4-deployment.7 → 1.2.4-deployment.9
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/{chunk-UC5S2WUP.js → chunk-R73CBIZK.js} +91 -100
- package/dist/http-server.js +2 -2
- package/dist/index.js +12 -9
- package/package.json +1 -1
|
@@ -7,7 +7,6 @@ import { promises as fs } from "fs";
|
|
|
7
7
|
import { exec } from "child_process";
|
|
8
8
|
import { promisify } from "util";
|
|
9
9
|
import { tmpdir } from "os";
|
|
10
|
-
import path from "path";
|
|
11
10
|
import archiver from "archiver";
|
|
12
11
|
|
|
13
12
|
// src/shared/response-handler.ts
|
|
@@ -1181,75 +1180,74 @@ var listDeploymentsResponseSchema = z20.object({
|
|
|
1181
1180
|
import FormData from "form-data";
|
|
1182
1181
|
var execAsync = promisify(exec);
|
|
1183
1182
|
var TOOL_VERSION_REQUIREMENTS = {
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1183
|
+
// Schedule tools - require backend v1.1.1+
|
|
1184
|
+
"upsert-schedule": { minVersion: "1.1.1" },
|
|
1185
|
+
"delete-schedule": { minVersion: "1.1.1" },
|
|
1186
|
+
// 'get-schedules': { minVersion: '1.1.1' },
|
|
1187
|
+
// 'get-schedule-logs': { minVersion: '1.1.1' },
|
|
1188
|
+
"create-deployment": { minVersion: "1.4.7" }
|
|
1189
|
+
// Example of a deprecated tool (uncomment when needed):
|
|
1190
|
+
// 'legacy-tool': { minVersion: '1.0.0', maxVersion: '1.5.0' },
|
|
1188
1191
|
};
|
|
1189
|
-
function
|
|
1190
|
-
const
|
|
1191
|
-
const
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
const
|
|
1197
|
-
if (
|
|
1198
|
-
|
|
1199
|
-
}
|
|
1200
|
-
try {
|
|
1201
|
-
const response = await fetch2(`${API_BASE_URL}/api/health`, {
|
|
1202
|
-
method: "GET",
|
|
1203
|
-
headers: {
|
|
1204
|
-
"Content-Type": "application/json"
|
|
1205
|
-
}
|
|
1206
|
-
});
|
|
1207
|
-
if (!response.ok) {
|
|
1208
|
-
throw new Error(`Health check failed with status ${response.status}`);
|
|
1209
|
-
}
|
|
1210
|
-
const health = await response.json();
|
|
1211
|
-
versionCache = {
|
|
1212
|
-
version: health.version,
|
|
1213
|
-
timestamp: now
|
|
1214
|
-
};
|
|
1215
|
-
return health.version;
|
|
1216
|
-
} catch (error) {
|
|
1217
|
-
const errMsg = error instanceof Error ? error.message : "Unknown error";
|
|
1218
|
-
throw new Error(`Failed to fetch backend version: ${errMsg}`);
|
|
1219
|
-
}
|
|
1192
|
+
function compareVersions(v1, v2) {
|
|
1193
|
+
const clean1 = v1.replace(/^v/, "").split("-")[0];
|
|
1194
|
+
const clean2 = v2.replace(/^v/, "").split("-")[0];
|
|
1195
|
+
const parts1 = clean1.split(".").map(Number);
|
|
1196
|
+
const parts2 = clean2.split(".").map(Number);
|
|
1197
|
+
for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
|
|
1198
|
+
const part1 = parts1[i] || 0;
|
|
1199
|
+
const part2 = parts2[i] || 0;
|
|
1200
|
+
if (part1 > part2) return 1;
|
|
1201
|
+
if (part1 < part2) return -1;
|
|
1220
1202
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
const part1 = parts1[i] || 0;
|
|
1228
|
-
const part2 = parts2[i] || 0;
|
|
1229
|
-
if (part1 > part2) return 1;
|
|
1230
|
-
if (part1 < part2) return -1;
|
|
1231
|
-
}
|
|
1232
|
-
return 0;
|
|
1203
|
+
return 0;
|
|
1204
|
+
}
|
|
1205
|
+
function shouldRegisterTool(toolName, backendVersion) {
|
|
1206
|
+
const requirement = TOOL_VERSION_REQUIREMENTS[toolName];
|
|
1207
|
+
if (!requirement) {
|
|
1208
|
+
return true;
|
|
1233
1209
|
}
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
throw error;
|
|
1249
|
-
}
|
|
1250
|
-
console.warn(`Warning: Could not verify backend version for tool '${toolName}': ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1210
|
+
const { minVersion, maxVersion } = requirement;
|
|
1211
|
+
if (minVersion && compareVersions(backendVersion, minVersion) < 0) {
|
|
1212
|
+
return false;
|
|
1213
|
+
}
|
|
1214
|
+
if (maxVersion && compareVersions(backendVersion, maxVersion) > 0) {
|
|
1215
|
+
return false;
|
|
1216
|
+
}
|
|
1217
|
+
return true;
|
|
1218
|
+
}
|
|
1219
|
+
async function fetchBackendVersion(apiBaseUrl) {
|
|
1220
|
+
const response = await fetch2(`${apiBaseUrl}/api/health`, {
|
|
1221
|
+
method: "GET",
|
|
1222
|
+
headers: {
|
|
1223
|
+
"Content-Type": "application/json"
|
|
1251
1224
|
}
|
|
1225
|
+
});
|
|
1226
|
+
if (!response.ok) {
|
|
1227
|
+
throw new Error(`Health check failed with status ${response.status}`);
|
|
1252
1228
|
}
|
|
1229
|
+
const health = await response.json();
|
|
1230
|
+
return health.version;
|
|
1231
|
+
}
|
|
1232
|
+
async function registerInsforgeTools(server, config = {}) {
|
|
1233
|
+
const GLOBAL_API_KEY = config.apiKey || process.env.API_KEY || "";
|
|
1234
|
+
const API_BASE_URL = config.apiBaseUrl || process.env.API_BASE_URL || "http://localhost:7130";
|
|
1235
|
+
const usageTracker = new UsageTracker(API_BASE_URL, GLOBAL_API_KEY);
|
|
1236
|
+
const backendVersion = await fetchBackendVersion(API_BASE_URL);
|
|
1237
|
+
console.error(`Backend version: ${backendVersion}`);
|
|
1238
|
+
let toolCount = 0;
|
|
1239
|
+
const registerTool = (toolName, ...args) => {
|
|
1240
|
+
if (shouldRegisterTool(toolName, backendVersion)) {
|
|
1241
|
+
server.tool(toolName, ...args);
|
|
1242
|
+
toolCount++;
|
|
1243
|
+
return true;
|
|
1244
|
+
} else {
|
|
1245
|
+
const req = TOOL_VERSION_REQUIREMENTS[toolName];
|
|
1246
|
+
const reason = req?.minVersion && compareVersions(backendVersion, req.minVersion) < 0 ? `requires backend >= ${req.minVersion}` : `deprecated after backend ${req?.maxVersion}`;
|
|
1247
|
+
console.error(`Skipping tool '${toolName}': ${reason} (current: ${backendVersion})`);
|
|
1248
|
+
return false;
|
|
1249
|
+
}
|
|
1250
|
+
};
|
|
1253
1251
|
async function trackToolUsage(toolName, success = true) {
|
|
1254
1252
|
if (GLOBAL_API_KEY) {
|
|
1255
1253
|
await usageTracker.trackUsage(toolName, success);
|
|
@@ -1306,28 +1304,23 @@ function registerInsforgeTools(server, config = {}) {
|
|
|
1306
1304
|
}
|
|
1307
1305
|
};
|
|
1308
1306
|
const addBackgroundContext = async (response) => {
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
const
|
|
1312
|
-
if (
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
type: "text",
|
|
1317
|
-
text: `
|
|
1307
|
+
const isLegacyVersion = compareVersions(backendVersion, "1.1.7") < 0;
|
|
1308
|
+
if (isLegacyVersion) {
|
|
1309
|
+
const context = await fetchInsforgeInstructionsContext();
|
|
1310
|
+
if (context && response.content && Array.isArray(response.content)) {
|
|
1311
|
+
response.content.push({
|
|
1312
|
+
type: "text",
|
|
1313
|
+
text: `
|
|
1318
1314
|
|
|
1319
1315
|
---
|
|
1320
1316
|
\u{1F527} INSFORGE DEVELOPMENT RULES (Auto-loaded):
|
|
1321
1317
|
${context}`
|
|
1322
|
-
|
|
1323
|
-
}
|
|
1318
|
+
});
|
|
1324
1319
|
}
|
|
1325
|
-
} catch {
|
|
1326
|
-
console.warn("Could not determine backend version, skipping background context");
|
|
1327
1320
|
}
|
|
1328
1321
|
return response;
|
|
1329
1322
|
};
|
|
1330
|
-
|
|
1323
|
+
registerTool(
|
|
1331
1324
|
"fetch-docs",
|
|
1332
1325
|
'Fetch Insforge documentation. Use "instructions" for essential backend setup (MANDATORY FIRST), or select specific SDK docs for database, auth, storage, functions, or AI integration.',
|
|
1333
1326
|
{
|
|
@@ -1360,7 +1353,7 @@ ${context}`
|
|
|
1360
1353
|
}
|
|
1361
1354
|
})
|
|
1362
1355
|
);
|
|
1363
|
-
|
|
1356
|
+
registerTool(
|
|
1364
1357
|
"get-anon-key",
|
|
1365
1358
|
"Generate an anonymous JWT token that never expires. Requires admin API key. Use this for client-side applications that need public access.",
|
|
1366
1359
|
{
|
|
@@ -1399,7 +1392,7 @@ ${context}`
|
|
|
1399
1392
|
}
|
|
1400
1393
|
})
|
|
1401
1394
|
);
|
|
1402
|
-
|
|
1395
|
+
registerTool(
|
|
1403
1396
|
"get-table-schema",
|
|
1404
1397
|
"Returns the detailed schema(including RLS, indexes, constraints, etc.) of a specific table",
|
|
1405
1398
|
{
|
|
@@ -1438,7 +1431,7 @@ ${context}`
|
|
|
1438
1431
|
}
|
|
1439
1432
|
})
|
|
1440
1433
|
);
|
|
1441
|
-
|
|
1434
|
+
registerTool(
|
|
1442
1435
|
"get-backend-metadata",
|
|
1443
1436
|
"Index all backend metadata",
|
|
1444
1437
|
{
|
|
@@ -1478,7 +1471,7 @@ ${JSON.stringify(metadata, null, 2)}`
|
|
|
1478
1471
|
}
|
|
1479
1472
|
})
|
|
1480
1473
|
);
|
|
1481
|
-
|
|
1474
|
+
registerTool(
|
|
1482
1475
|
"run-raw-sql",
|
|
1483
1476
|
"Execute raw SQL query with optional parameters. Admin access required. Use with caution as it can modify data directly.",
|
|
1484
1477
|
{
|
|
@@ -1523,7 +1516,7 @@ ${JSON.stringify(metadata, null, 2)}`
|
|
|
1523
1516
|
}
|
|
1524
1517
|
})
|
|
1525
1518
|
);
|
|
1526
|
-
|
|
1519
|
+
registerTool(
|
|
1527
1520
|
"download-template",
|
|
1528
1521
|
"CRITICAL: MANDATORY FIRST STEP for all new InsForge projects. Download pre-configured starter template to a temporary directory. After download, you MUST copy files to current directory using the provided command.",
|
|
1529
1522
|
{
|
|
@@ -1599,7 +1592,7 @@ To: Your current project directory
|
|
|
1599
1592
|
}
|
|
1600
1593
|
})
|
|
1601
1594
|
);
|
|
1602
|
-
|
|
1595
|
+
registerTool(
|
|
1603
1596
|
"bulk-upsert",
|
|
1604
1597
|
"Bulk insert or update data from CSV or JSON file. Supports upsert operations with a unique key.",
|
|
1605
1598
|
{
|
|
@@ -1656,7 +1649,7 @@ To: Your current project directory
|
|
|
1656
1649
|
}
|
|
1657
1650
|
})
|
|
1658
1651
|
);
|
|
1659
|
-
|
|
1652
|
+
registerTool(
|
|
1660
1653
|
"create-bucket",
|
|
1661
1654
|
"Create new storage bucket",
|
|
1662
1655
|
{
|
|
@@ -1697,7 +1690,7 @@ To: Your current project directory
|
|
|
1697
1690
|
}
|
|
1698
1691
|
})
|
|
1699
1692
|
);
|
|
1700
|
-
|
|
1693
|
+
registerTool(
|
|
1701
1694
|
"list-buckets",
|
|
1702
1695
|
"Lists all storage buckets",
|
|
1703
1696
|
{},
|
|
@@ -1732,7 +1725,7 @@ To: Your current project directory
|
|
|
1732
1725
|
}
|
|
1733
1726
|
})
|
|
1734
1727
|
);
|
|
1735
|
-
|
|
1728
|
+
registerTool(
|
|
1736
1729
|
"delete-bucket",
|
|
1737
1730
|
"Deletes a storage bucket",
|
|
1738
1731
|
{
|
|
@@ -1771,7 +1764,7 @@ To: Your current project directory
|
|
|
1771
1764
|
}
|
|
1772
1765
|
})
|
|
1773
1766
|
);
|
|
1774
|
-
|
|
1767
|
+
registerTool(
|
|
1775
1768
|
"create-function",
|
|
1776
1769
|
"Create a new edge function that runs in Deno runtime. The code must be written to a file first for version control",
|
|
1777
1770
|
{
|
|
@@ -1830,7 +1823,7 @@ To: Your current project directory
|
|
|
1830
1823
|
}
|
|
1831
1824
|
})
|
|
1832
1825
|
);
|
|
1833
|
-
|
|
1826
|
+
registerTool(
|
|
1834
1827
|
"get-function",
|
|
1835
1828
|
"Get details of a specific edge function including its code",
|
|
1836
1829
|
{
|
|
@@ -1867,7 +1860,7 @@ To: Your current project directory
|
|
|
1867
1860
|
}
|
|
1868
1861
|
})
|
|
1869
1862
|
);
|
|
1870
|
-
|
|
1863
|
+
registerTool(
|
|
1871
1864
|
"update-function",
|
|
1872
1865
|
"Update an existing edge function code or metadata",
|
|
1873
1866
|
{
|
|
@@ -1933,7 +1926,7 @@ To: Your current project directory
|
|
|
1933
1926
|
}
|
|
1934
1927
|
})
|
|
1935
1928
|
);
|
|
1936
|
-
|
|
1929
|
+
registerTool(
|
|
1937
1930
|
"delete-function",
|
|
1938
1931
|
"Delete an edge function permanently",
|
|
1939
1932
|
{
|
|
@@ -1970,7 +1963,7 @@ To: Your current project directory
|
|
|
1970
1963
|
}
|
|
1971
1964
|
})
|
|
1972
1965
|
);
|
|
1973
|
-
|
|
1966
|
+
registerTool(
|
|
1974
1967
|
"get-container-logs",
|
|
1975
1968
|
"Get latest logs from a specific container/service. Use this to help debug problems with your app.",
|
|
1976
1969
|
{
|
|
@@ -2020,16 +2013,16 @@ To: Your current project directory
|
|
|
2020
2013
|
}
|
|
2021
2014
|
})
|
|
2022
2015
|
);
|
|
2023
|
-
|
|
2016
|
+
registerTool(
|
|
2024
2017
|
"create-deployment",
|
|
2025
2018
|
"Deploy source code from a directory. This tool zips files, uploads to cloud storage, and triggers deployment with optional environment variables and project settings.",
|
|
2026
2019
|
{
|
|
2027
|
-
sourceDirectory: z21.string().describe(
|
|
2020
|
+
sourceDirectory: z21.string().describe('Absolute path to the source directory containing files to deploy (e.g., /Users/name/project or C:\\Users\\name\\project). Do not use relative paths like "."'),
|
|
2028
2021
|
...startDeploymentRequestSchema.shape
|
|
2029
2022
|
},
|
|
2030
2023
|
withUsageTracking("create-deployment", async ({ sourceDirectory, projectSettings, envVars, meta }) => {
|
|
2031
2024
|
try {
|
|
2032
|
-
const resolvedSourceDir =
|
|
2025
|
+
const resolvedSourceDir = sourceDirectory;
|
|
2033
2026
|
const createResponse = await fetch2(`${API_BASE_URL}/api/deployments`, {
|
|
2034
2027
|
method: "POST",
|
|
2035
2028
|
headers: {
|
|
@@ -2045,9 +2038,6 @@ To: Your current project directory
|
|
|
2045
2038
|
archive.on("data", (chunk) => chunks.push(chunk));
|
|
2046
2039
|
archive.on("end", () => resolve(Buffer.concat(chunks)));
|
|
2047
2040
|
archive.on("error", (err) => reject(err));
|
|
2048
|
-
archive.on("warning", (err) => {
|
|
2049
|
-
console.warn("Archiver warning:", err.message);
|
|
2050
|
-
});
|
|
2051
2041
|
const excludePatterns = [
|
|
2052
2042
|
"node_modules",
|
|
2053
2043
|
".git",
|
|
@@ -2126,7 +2116,8 @@ To: Your current project directory
|
|
|
2126
2116
|
return {
|
|
2127
2117
|
apiKey: GLOBAL_API_KEY,
|
|
2128
2118
|
apiBaseUrl: API_BASE_URL,
|
|
2129
|
-
toolCount
|
|
2119
|
+
toolCount,
|
|
2120
|
+
backendVersion
|
|
2130
2121
|
};
|
|
2131
2122
|
}
|
|
2132
2123
|
|
package/dist/http-server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
registerInsforgeTools
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-R73CBIZK.js";
|
|
5
5
|
|
|
6
6
|
// src/http/server.ts
|
|
7
7
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -91,7 +91,7 @@ app.post("/mcp", async (req, res) => {
|
|
|
91
91
|
name: "insforge-mcp",
|
|
92
92
|
version: "1.0.0"
|
|
93
93
|
});
|
|
94
|
-
registerInsforgeTools(mcpServer, {
|
|
94
|
+
await registerInsforgeTools(mcpServer, {
|
|
95
95
|
apiKey,
|
|
96
96
|
apiBaseUrl
|
|
97
97
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
registerInsforgeTools
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-R73CBIZK.js";
|
|
5
5
|
|
|
6
6
|
// src/stdio/index.ts
|
|
7
7
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -12,15 +12,15 @@ program.option("--api_base_url <value>", "API Base URL");
|
|
|
12
12
|
program.parse(process.argv);
|
|
13
13
|
var options = program.opts();
|
|
14
14
|
var { api_key, api_base_url } = options;
|
|
15
|
-
var server = new McpServer({
|
|
16
|
-
name: "insforge-mcp",
|
|
17
|
-
version: "1.0.0"
|
|
18
|
-
});
|
|
19
|
-
var toolsConfig = registerInsforgeTools(server, {
|
|
20
|
-
apiKey: api_key,
|
|
21
|
-
apiBaseUrl: api_base_url || process.env.API_BASE_URL
|
|
22
|
-
});
|
|
23
15
|
async function main() {
|
|
16
|
+
const server = new McpServer({
|
|
17
|
+
name: "insforge-mcp",
|
|
18
|
+
version: "1.0.0"
|
|
19
|
+
});
|
|
20
|
+
const toolsConfig = await registerInsforgeTools(server, {
|
|
21
|
+
apiKey: api_key,
|
|
22
|
+
apiBaseUrl: api_base_url || process.env.API_BASE_URL
|
|
23
|
+
});
|
|
24
24
|
const transport = new StdioServerTransport();
|
|
25
25
|
await server.connect(transport);
|
|
26
26
|
console.error("Insforge MCP server started");
|
|
@@ -30,6 +30,9 @@ async function main() {
|
|
|
30
30
|
console.error("API Key: Not configured (will require api_key in tool calls)");
|
|
31
31
|
}
|
|
32
32
|
console.error(`API Base URL: ${toolsConfig.apiBaseUrl}`);
|
|
33
|
+
if (toolsConfig.backendVersion) {
|
|
34
|
+
console.error(`Backend Version: ${toolsConfig.backendVersion}`);
|
|
35
|
+
}
|
|
33
36
|
console.error(`Tools registered: ${toolsConfig.toolCount}`);
|
|
34
37
|
}
|
|
35
38
|
main().catch(console.error);
|
package/package.json
CHANGED