@insforge/mcp 1.2.4-deployment.7 → 1.2.4-deployment.8

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.
@@ -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,75 @@ var listDeploymentsResponseSchema = z20.object({
1181
1180
  import FormData from "form-data";
1182
1181
  var execAsync = promisify(exec);
1183
1182
  var TOOL_VERSION_REQUIREMENTS = {
1184
- "upsert-schedule": "1.1.1",
1185
- // 'get-schedules': '1.1.1',
1186
- // 'get-schedule-logs': '1.1.1',
1187
- "delete-schedule": "1.1.1"
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
+ // Deployment tools - require backend v1.2.0+
1189
+ "create-deployment": { minVersion: "1.2.0" }
1190
+ // Example of a deprecated tool (uncomment when needed):
1191
+ // 'legacy-tool': { minVersion: '1.0.0', maxVersion: '1.5.0' },
1188
1192
  };
1189
- function registerInsforgeTools(server, config = {}) {
1190
- const GLOBAL_API_KEY = config.apiKey || process.env.API_KEY || "";
1191
- const API_BASE_URL = config.apiBaseUrl || process.env.API_BASE_URL || "http://localhost:7130";
1192
- const usageTracker = new UsageTracker(API_BASE_URL, GLOBAL_API_KEY);
1193
- let versionCache = null;
1194
- const VERSION_CACHE_TTL = 5 * 60 * 1e3;
1195
- async function getBackendVersion() {
1196
- const now = Date.now();
1197
- if (versionCache && now - versionCache.timestamp < VERSION_CACHE_TTL) {
1198
- return versionCache.version;
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
- }
1193
+ function compareVersions(v1, v2) {
1194
+ const clean1 = v1.replace(/^v/, "").split("-")[0];
1195
+ const clean2 = v2.replace(/^v/, "").split("-")[0];
1196
+ const parts1 = clean1.split(".").map(Number);
1197
+ const parts2 = clean2.split(".").map(Number);
1198
+ for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
1199
+ const part1 = parts1[i] || 0;
1200
+ const part2 = parts2[i] || 0;
1201
+ if (part1 > part2) return 1;
1202
+ if (part1 < part2) return -1;
1220
1203
  }
1221
- function compareVersions(v1, v2) {
1222
- const clean1 = v1.replace(/^v/, "").split("-")[0];
1223
- const clean2 = v2.replace(/^v/, "").split("-")[0];
1224
- const parts1 = clean1.split(".").map(Number);
1225
- const parts2 = clean2.split(".").map(Number);
1226
- for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
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;
1204
+ return 0;
1205
+ }
1206
+ function shouldRegisterTool(toolName, backendVersion) {
1207
+ const requirement = TOOL_VERSION_REQUIREMENTS[toolName];
1208
+ if (!requirement) {
1209
+ return true;
1233
1210
  }
1234
- async function checkToolVersion(toolName) {
1235
- const requiredVersion = TOOL_VERSION_REQUIREMENTS[toolName];
1236
- if (!requiredVersion) {
1237
- return;
1238
- }
1239
- try {
1240
- const currentVersion = await getBackendVersion();
1241
- if (compareVersions(currentVersion, requiredVersion) < 0) {
1242
- throw new Error(
1243
- `Tool '${toolName}' requires backend version ${requiredVersion} or higher, but current version is ${currentVersion}. Please upgrade your Insforge backend server.`
1244
- );
1245
- }
1246
- } catch (error) {
1247
- if (error instanceof Error && error.message.includes("requires backend version")) {
1248
- throw error;
1249
- }
1250
- console.warn(`Warning: Could not verify backend version for tool '${toolName}': ${error instanceof Error ? error.message : "Unknown error"}`);
1211
+ const { minVersion, maxVersion } = requirement;
1212
+ if (minVersion && compareVersions(backendVersion, minVersion) < 0) {
1213
+ return false;
1214
+ }
1215
+ if (maxVersion && compareVersions(backendVersion, maxVersion) > 0) {
1216
+ return false;
1217
+ }
1218
+ return true;
1219
+ }
1220
+ async function fetchBackendVersion(apiBaseUrl) {
1221
+ const response = await fetch2(`${apiBaseUrl}/api/health`, {
1222
+ method: "GET",
1223
+ headers: {
1224
+ "Content-Type": "application/json"
1251
1225
  }
1226
+ });
1227
+ if (!response.ok) {
1228
+ throw new Error(`Health check failed with status ${response.status}`);
1252
1229
  }
1230
+ const health = await response.json();
1231
+ return health.version;
1232
+ }
1233
+ async function registerInsforgeTools(server, config = {}) {
1234
+ const GLOBAL_API_KEY = config.apiKey || process.env.API_KEY || "";
1235
+ const API_BASE_URL = config.apiBaseUrl || process.env.API_BASE_URL || "http://localhost:7130";
1236
+ const usageTracker = new UsageTracker(API_BASE_URL, GLOBAL_API_KEY);
1237
+ const backendVersion = await fetchBackendVersion(API_BASE_URL);
1238
+ console.error(`Backend version: ${backendVersion}`);
1239
+ let toolCount = 0;
1240
+ const registerTool = (toolName, ...args) => {
1241
+ if (shouldRegisterTool(toolName, backendVersion)) {
1242
+ server.tool(toolName, ...args);
1243
+ toolCount++;
1244
+ return true;
1245
+ } else {
1246
+ const req = TOOL_VERSION_REQUIREMENTS[toolName];
1247
+ const reason = req?.minVersion && compareVersions(backendVersion, req.minVersion) < 0 ? `requires backend >= ${req.minVersion}` : `deprecated after backend ${req?.maxVersion}`;
1248
+ console.error(`Skipping tool '${toolName}': ${reason} (current: ${backendVersion})`);
1249
+ return false;
1250
+ }
1251
+ };
1253
1252
  async function trackToolUsage(toolName, success = true) {
1254
1253
  if (GLOBAL_API_KEY) {
1255
1254
  await usageTracker.trackUsage(toolName, success);
@@ -1306,28 +1305,23 @@ function registerInsforgeTools(server, config = {}) {
1306
1305
  }
1307
1306
  };
1308
1307
  const addBackgroundContext = async (response) => {
1309
- try {
1310
- const currentVersion = await getBackendVersion();
1311
- const isLegacyVersion = compareVersions(currentVersion, "1.1.7") < 0;
1312
- if (isLegacyVersion) {
1313
- const context = await fetchInsforgeInstructionsContext();
1314
- if (context && response.content && Array.isArray(response.content)) {
1315
- response.content.push({
1316
- type: "text",
1317
- text: `
1308
+ const isLegacyVersion = compareVersions(backendVersion, "1.1.7") < 0;
1309
+ if (isLegacyVersion) {
1310
+ const context = await fetchInsforgeInstructionsContext();
1311
+ if (context && response.content && Array.isArray(response.content)) {
1312
+ response.content.push({
1313
+ type: "text",
1314
+ text: `
1318
1315
 
1319
1316
  ---
1320
1317
  \u{1F527} INSFORGE DEVELOPMENT RULES (Auto-loaded):
1321
1318
  ${context}`
1322
- });
1323
- }
1319
+ });
1324
1320
  }
1325
- } catch {
1326
- console.warn("Could not determine backend version, skipping background context");
1327
1321
  }
1328
1322
  return response;
1329
1323
  };
1330
- server.tool(
1324
+ registerTool(
1331
1325
  "fetch-docs",
1332
1326
  '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
1327
  {
@@ -1360,7 +1354,7 @@ ${context}`
1360
1354
  }
1361
1355
  })
1362
1356
  );
1363
- server.tool(
1357
+ registerTool(
1364
1358
  "get-anon-key",
1365
1359
  "Generate an anonymous JWT token that never expires. Requires admin API key. Use this for client-side applications that need public access.",
1366
1360
  {
@@ -1399,7 +1393,7 @@ ${context}`
1399
1393
  }
1400
1394
  })
1401
1395
  );
1402
- server.tool(
1396
+ registerTool(
1403
1397
  "get-table-schema",
1404
1398
  "Returns the detailed schema(including RLS, indexes, constraints, etc.) of a specific table",
1405
1399
  {
@@ -1438,7 +1432,7 @@ ${context}`
1438
1432
  }
1439
1433
  })
1440
1434
  );
1441
- server.tool(
1435
+ registerTool(
1442
1436
  "get-backend-metadata",
1443
1437
  "Index all backend metadata",
1444
1438
  {
@@ -1478,7 +1472,7 @@ ${JSON.stringify(metadata, null, 2)}`
1478
1472
  }
1479
1473
  })
1480
1474
  );
1481
- server.tool(
1475
+ registerTool(
1482
1476
  "run-raw-sql",
1483
1477
  "Execute raw SQL query with optional parameters. Admin access required. Use with caution as it can modify data directly.",
1484
1478
  {
@@ -1523,7 +1517,7 @@ ${JSON.stringify(metadata, null, 2)}`
1523
1517
  }
1524
1518
  })
1525
1519
  );
1526
- server.tool(
1520
+ registerTool(
1527
1521
  "download-template",
1528
1522
  "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
1523
  {
@@ -1599,7 +1593,7 @@ To: Your current project directory
1599
1593
  }
1600
1594
  })
1601
1595
  );
1602
- server.tool(
1596
+ registerTool(
1603
1597
  "bulk-upsert",
1604
1598
  "Bulk insert or update data from CSV or JSON file. Supports upsert operations with a unique key.",
1605
1599
  {
@@ -1656,7 +1650,7 @@ To: Your current project directory
1656
1650
  }
1657
1651
  })
1658
1652
  );
1659
- server.tool(
1653
+ registerTool(
1660
1654
  "create-bucket",
1661
1655
  "Create new storage bucket",
1662
1656
  {
@@ -1697,7 +1691,7 @@ To: Your current project directory
1697
1691
  }
1698
1692
  })
1699
1693
  );
1700
- server.tool(
1694
+ registerTool(
1701
1695
  "list-buckets",
1702
1696
  "Lists all storage buckets",
1703
1697
  {},
@@ -1732,7 +1726,7 @@ To: Your current project directory
1732
1726
  }
1733
1727
  })
1734
1728
  );
1735
- server.tool(
1729
+ registerTool(
1736
1730
  "delete-bucket",
1737
1731
  "Deletes a storage bucket",
1738
1732
  {
@@ -1771,7 +1765,7 @@ To: Your current project directory
1771
1765
  }
1772
1766
  })
1773
1767
  );
1774
- server.tool(
1768
+ registerTool(
1775
1769
  "create-function",
1776
1770
  "Create a new edge function that runs in Deno runtime. The code must be written to a file first for version control",
1777
1771
  {
@@ -1830,7 +1824,7 @@ To: Your current project directory
1830
1824
  }
1831
1825
  })
1832
1826
  );
1833
- server.tool(
1827
+ registerTool(
1834
1828
  "get-function",
1835
1829
  "Get details of a specific edge function including its code",
1836
1830
  {
@@ -1867,7 +1861,7 @@ To: Your current project directory
1867
1861
  }
1868
1862
  })
1869
1863
  );
1870
- server.tool(
1864
+ registerTool(
1871
1865
  "update-function",
1872
1866
  "Update an existing edge function code or metadata",
1873
1867
  {
@@ -1933,7 +1927,7 @@ To: Your current project directory
1933
1927
  }
1934
1928
  })
1935
1929
  );
1936
- server.tool(
1930
+ registerTool(
1937
1931
  "delete-function",
1938
1932
  "Delete an edge function permanently",
1939
1933
  {
@@ -1970,7 +1964,7 @@ To: Your current project directory
1970
1964
  }
1971
1965
  })
1972
1966
  );
1973
- server.tool(
1967
+ registerTool(
1974
1968
  "get-container-logs",
1975
1969
  "Get latest logs from a specific container/service. Use this to help debug problems with your app.",
1976
1970
  {
@@ -2020,16 +2014,16 @@ To: Your current project directory
2020
2014
  }
2021
2015
  })
2022
2016
  );
2023
- server.tool(
2017
+ registerTool(
2024
2018
  "create-deployment",
2025
2019
  "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
2020
  {
2027
- sourceDirectory: z21.string().describe("Path to the source directory containing files to deploy"),
2021
+ 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
2022
  ...startDeploymentRequestSchema.shape
2029
2023
  },
2030
2024
  withUsageTracking("create-deployment", async ({ sourceDirectory, projectSettings, envVars, meta }) => {
2031
2025
  try {
2032
- const resolvedSourceDir = path.resolve(sourceDirectory);
2026
+ const resolvedSourceDir = sourceDirectory;
2033
2027
  const createResponse = await fetch2(`${API_BASE_URL}/api/deployments`, {
2034
2028
  method: "POST",
2035
2029
  headers: {
@@ -2045,9 +2039,6 @@ To: Your current project directory
2045
2039
  archive.on("data", (chunk) => chunks.push(chunk));
2046
2040
  archive.on("end", () => resolve(Buffer.concat(chunks)));
2047
2041
  archive.on("error", (err) => reject(err));
2048
- archive.on("warning", (err) => {
2049
- console.warn("Archiver warning:", err.message);
2050
- });
2051
2042
  const excludePatterns = [
2052
2043
  "node_modules",
2053
2044
  ".git",
@@ -2126,7 +2117,8 @@ To: Your current project directory
2126
2117
  return {
2127
2118
  apiKey: GLOBAL_API_KEY,
2128
2119
  apiBaseUrl: API_BASE_URL,
2129
- toolCount: 16
2120
+ toolCount,
2121
+ backendVersion
2130
2122
  };
2131
2123
  }
2132
2124
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  registerInsforgeTools
4
- } from "./chunk-UC5S2WUP.js";
4
+ } from "./chunk-O33PL3H4.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-UC5S2WUP.js";
4
+ } from "./chunk-O33PL3H4.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insforge/mcp",
3
- "version": "1.2.4-deployment.7",
3
+ "version": "1.2.4-deployment.8",
4
4
  "description": "MCP (Model Context Protocol) server for Insforge backend-as-a-service",
5
5
  "mcpName": "io.github.InsForge/insforge-mcp",
6
6
  "type": "module",