@insforge/mcp 1.1.5-dev.1 → 1.1.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.
@@ -778,6 +778,28 @@ function registerInsforgeTools(server, config = {}) {
778
778
  throw new Error(`Unable to retrieve ${docType} documentation: ${errMsg}`);
779
779
  }
780
780
  };
781
+ const fetchInsforgeInstructionsContext = async () => {
782
+ try {
783
+ return await fetchDocumentation("instructions");
784
+ } catch (error) {
785
+ console.error("Failed to fetch insforge-instructions.md:", error);
786
+ return null;
787
+ }
788
+ };
789
+ const addBackgroundContext = async (response) => {
790
+ const context = await fetchInsforgeInstructionsContext();
791
+ if (context && response.content && Array.isArray(response.content)) {
792
+ response.content.push({
793
+ type: "text",
794
+ text: `
795
+
796
+ ---
797
+ \u{1F527} INSFORGE DEVELOPMENT RULES (Auto-loaded):
798
+ ${context}`
799
+ });
800
+ }
801
+ return response;
802
+ };
781
803
  server.tool(
782
804
  "get-instructions",
783
805
  "Instruction Essential backend setup tool. <critical>MANDATORY: You MUST use this tool FIRST before attempting any backend operations. Contains required API endpoints, authentication details, and setup instructions.</critical>",
@@ -785,7 +807,7 @@ function registerInsforgeTools(server, config = {}) {
785
807
  withUsageTracking("get-instructions", async () => {
786
808
  try {
787
809
  const content = await fetchDocumentation("instructions");
788
- return {
810
+ const response = {
789
811
  content: [
790
812
  {
791
813
  type: "text",
@@ -793,11 +815,13 @@ function registerInsforgeTools(server, config = {}) {
793
815
  }
794
816
  ]
795
817
  };
818
+ return await addBackgroundContext(response);
796
819
  } catch (error) {
797
820
  const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
798
- return {
821
+ const errorResponse = {
799
822
  content: [{ type: "text", text: `Error: ${errMsg}` }]
800
823
  };
824
+ return await addBackgroundContext(errorResponse);
801
825
  }
802
826
  })
803
827
  );
@@ -807,14 +831,14 @@ function registerInsforgeTools(server, config = {}) {
807
831
  {},
808
832
  async () => {
809
833
  try {
810
- return {
834
+ return await addBackgroundContext({
811
835
  content: [{ type: "text", text: `API key: ${getApiKey()}` }]
812
- };
836
+ });
813
837
  } catch (error) {
814
838
  const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
815
- return {
839
+ return await addBackgroundContext({
816
840
  content: [{ type: "text", text: `Error: ${errMsg}` }]
817
- };
841
+ });
818
842
  }
819
843
  }
820
844
  );
@@ -835,17 +859,17 @@ function registerInsforgeTools(server, config = {}) {
835
859
  }
836
860
  });
837
861
  const result = await handleApiResponse(response);
838
- return {
862
+ return await addBackgroundContext({
839
863
  content: [
840
864
  {
841
865
  type: "text",
842
866
  text: formatSuccessMessage("Schema retrieved", result)
843
867
  }
844
868
  ]
845
- };
869
+ });
846
870
  } catch (error) {
847
871
  const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
848
- return {
872
+ return await addBackgroundContext({
849
873
  content: [
850
874
  {
851
875
  type: "text",
@@ -853,7 +877,7 @@ function registerInsforgeTools(server, config = {}) {
853
877
  }
854
878
  ],
855
879
  isError: true
856
- };
880
+ });
857
881
  }
858
882
  })
859
883
  );
@@ -873,7 +897,7 @@ function registerInsforgeTools(server, config = {}) {
873
897
  }
874
898
  });
875
899
  const metadata = await handleApiResponse(response);
876
- return {
900
+ return await addBackgroundContext({
877
901
  content: [
878
902
  {
879
903
  type: "text",
@@ -882,10 +906,10 @@ function registerInsforgeTools(server, config = {}) {
882
906
  ${JSON.stringify(metadata, null, 2)}`
883
907
  }
884
908
  ]
885
- };
909
+ });
886
910
  } catch (error) {
887
911
  const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
888
- return {
912
+ return await addBackgroundContext({
889
913
  content: [
890
914
  {
891
915
  type: "text",
@@ -893,7 +917,7 @@ ${JSON.stringify(metadata, null, 2)}`
893
917
  }
894
918
  ],
895
919
  isError: true
896
- };
920
+ });
897
921
  }
898
922
  })
899
923
  );
@@ -920,17 +944,17 @@ ${JSON.stringify(metadata, null, 2)}`
920
944
  body: JSON.stringify(requestBody)
921
945
  });
922
946
  const result = await handleApiResponse(response);
923
- return {
947
+ return await addBackgroundContext({
924
948
  content: [
925
949
  {
926
950
  type: "text",
927
951
  text: formatSuccessMessage("SQL query executed", result)
928
952
  }
929
953
  ]
930
- };
954
+ });
931
955
  } catch (error) {
932
956
  const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
933
- return {
957
+ return await addBackgroundContext({
934
958
  content: [
935
959
  {
936
960
  type: "text",
@@ -938,7 +962,7 @@ ${JSON.stringify(metadata, null, 2)}`
938
962
  }
939
963
  ],
940
964
  isError: true
941
- };
965
+ });
942
966
  }
943
967
  })
944
968
  );
@@ -971,7 +995,7 @@ ${JSON.stringify(metadata, null, 2)}`
971
995
  });
972
996
  const result = await handleApiResponse(response);
973
997
  const message = result.success ? `Successfully processed ${result.rowsAffected} of ${result.totalRecords} records into table "${result.table}"` : result.message || "Bulk upsert operation completed";
974
- return {
998
+ return await addBackgroundContext({
975
999
  content: [
976
1000
  {
977
1001
  type: "text",
@@ -984,10 +1008,10 @@ ${JSON.stringify(metadata, null, 2)}`
984
1008
  })
985
1009
  }
986
1010
  ]
987
- };
1011
+ });
988
1012
  } catch (error) {
989
1013
  const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
990
- return {
1014
+ return await addBackgroundContext({
991
1015
  content: [
992
1016
  {
993
1017
  type: "text",
@@ -995,7 +1019,7 @@ ${JSON.stringify(metadata, null, 2)}`
995
1019
  }
996
1020
  ],
997
1021
  isError: true
998
- };
1022
+ });
999
1023
  }
1000
1024
  })
1001
1025
  );
@@ -1018,17 +1042,17 @@ ${JSON.stringify(metadata, null, 2)}`
1018
1042
  body: JSON.stringify({ bucketName, isPublic })
1019
1043
  });
1020
1044
  const result = await handleApiResponse(response);
1021
- return {
1045
+ return await addBackgroundContext({
1022
1046
  content: [
1023
1047
  {
1024
1048
  type: "text",
1025
1049
  text: formatSuccessMessage("Bucket created", result)
1026
1050
  }
1027
1051
  ]
1028
- };
1052
+ });
1029
1053
  } catch (error) {
1030
1054
  const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
1031
- return {
1055
+ return await addBackgroundContext({
1032
1056
  content: [
1033
1057
  {
1034
1058
  type: "text",
@@ -1036,7 +1060,7 @@ ${JSON.stringify(metadata, null, 2)}`
1036
1060
  }
1037
1061
  ],
1038
1062
  isError: true
1039
- };
1063
+ });
1040
1064
  }
1041
1065
  })
1042
1066
  );
@@ -1053,17 +1077,17 @@ ${JSON.stringify(metadata, null, 2)}`
1053
1077
  }
1054
1078
  });
1055
1079
  const result = await handleApiResponse(response);
1056
- return {
1080
+ return await addBackgroundContext({
1057
1081
  content: [
1058
1082
  {
1059
1083
  type: "text",
1060
1084
  text: formatSuccessMessage("Buckets retrieved", result)
1061
1085
  }
1062
1086
  ]
1063
- };
1087
+ });
1064
1088
  } catch (error) {
1065
1089
  const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
1066
- return {
1090
+ return await addBackgroundContext({
1067
1091
  content: [
1068
1092
  {
1069
1093
  type: "text",
@@ -1071,7 +1095,7 @@ ${JSON.stringify(metadata, null, 2)}`
1071
1095
  }
1072
1096
  ],
1073
1097
  isError: true
1074
- };
1098
+ });
1075
1099
  }
1076
1100
  })
1077
1101
  );
@@ -1092,17 +1116,17 @@ ${JSON.stringify(metadata, null, 2)}`
1092
1116
  }
1093
1117
  });
1094
1118
  const result = await handleApiResponse(response);
1095
- return {
1119
+ return await addBackgroundContext({
1096
1120
  content: [
1097
1121
  {
1098
1122
  type: "text",
1099
1123
  text: formatSuccessMessage("Bucket deleted", result)
1100
1124
  }
1101
1125
  ]
1102
- };
1126
+ });
1103
1127
  } catch (error) {
1104
1128
  const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
1105
- return {
1129
+ return await addBackgroundContext({
1106
1130
  content: [
1107
1131
  {
1108
1132
  type: "text",
@@ -1110,7 +1134,7 @@ ${JSON.stringify(metadata, null, 2)}`
1110
1134
  }
1111
1135
  ],
1112
1136
  isError: true
1113
- };
1137
+ });
1114
1138
  }
1115
1139
  })
1116
1140
  );
@@ -1148,7 +1172,7 @@ ${JSON.stringify(metadata, null, 2)}`
1148
1172
  })
1149
1173
  });
1150
1174
  const result = await handleApiResponse(response);
1151
- return {
1175
+ return await addBackgroundContext({
1152
1176
  content: [
1153
1177
  {
1154
1178
  type: "text",
@@ -1158,10 +1182,10 @@ ${JSON.stringify(metadata, null, 2)}`
1158
1182
  )
1159
1183
  }
1160
1184
  ]
1161
- };
1185
+ });
1162
1186
  } catch (error) {
1163
1187
  const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
1164
- return {
1188
+ return await addBackgroundContext({
1165
1189
  content: [
1166
1190
  {
1167
1191
  type: "text",
@@ -1169,7 +1193,7 @@ ${JSON.stringify(metadata, null, 2)}`
1169
1193
  }
1170
1194
  ],
1171
1195
  isError: true
1172
- };
1196
+ });
1173
1197
  }
1174
1198
  })
1175
1199
  );
@@ -1188,17 +1212,17 @@ ${JSON.stringify(metadata, null, 2)}`
1188
1212
  }
1189
1213
  });
1190
1214
  const result = await handleApiResponse(response);
1191
- return {
1215
+ return await addBackgroundContext({
1192
1216
  content: [
1193
1217
  {
1194
1218
  type: "text",
1195
1219
  text: formatSuccessMessage(`Edge function '${args.slug}' details`, result)
1196
1220
  }
1197
1221
  ]
1198
- };
1222
+ });
1199
1223
  } catch (error) {
1200
1224
  const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
1201
- return {
1225
+ return await addBackgroundContext({
1202
1226
  content: [
1203
1227
  {
1204
1228
  type: "text",
@@ -1206,7 +1230,7 @@ ${JSON.stringify(metadata, null, 2)}`
1206
1230
  }
1207
1231
  ],
1208
1232
  isError: true
1209
- };
1233
+ });
1210
1234
  }
1211
1235
  })
1212
1236
  );
@@ -1251,7 +1275,7 @@ ${JSON.stringify(metadata, null, 2)}`
1251
1275
  });
1252
1276
  const result = await handleApiResponse(response);
1253
1277
  const fileInfo = args.codeFile ? ` from ${args.codeFile}` : "";
1254
- return {
1278
+ return await addBackgroundContext({
1255
1279
  content: [
1256
1280
  {
1257
1281
  type: "text",
@@ -1261,10 +1285,10 @@ ${JSON.stringify(metadata, null, 2)}`
1261
1285
  )
1262
1286
  }
1263
1287
  ]
1264
- };
1288
+ });
1265
1289
  } catch (error) {
1266
1290
  const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
1267
- return {
1291
+ return await addBackgroundContext({
1268
1292
  content: [
1269
1293
  {
1270
1294
  type: "text",
@@ -1272,7 +1296,7 @@ ${JSON.stringify(metadata, null, 2)}`
1272
1296
  }
1273
1297
  ],
1274
1298
  isError: true
1275
- };
1299
+ });
1276
1300
  }
1277
1301
  })
1278
1302
  );
@@ -1291,17 +1315,17 @@ ${JSON.stringify(metadata, null, 2)}`
1291
1315
  }
1292
1316
  });
1293
1317
  const result = await handleApiResponse(response);
1294
- return {
1318
+ return await addBackgroundContext({
1295
1319
  content: [
1296
1320
  {
1297
1321
  type: "text",
1298
1322
  text: formatSuccessMessage(`Edge function '${args.slug}' deleted successfully`, result)
1299
1323
  }
1300
1324
  ]
1301
- };
1325
+ });
1302
1326
  } catch (error) {
1303
1327
  const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
1304
- return {
1328
+ return await addBackgroundContext({
1305
1329
  content: [
1306
1330
  {
1307
1331
  type: "text",
@@ -1309,7 +1333,7 @@ ${JSON.stringify(metadata, null, 2)}`
1309
1333
  }
1310
1334
  ],
1311
1335
  isError: true
1312
- };
1336
+ });
1313
1337
  }
1314
1338
  })
1315
1339
  );
@@ -1326,24 +1350,32 @@ ${JSON.stringify(metadata, null, 2)}`
1326
1350
  const actualApiKey = getApiKey(apiKey);
1327
1351
  const queryParams = new URLSearchParams();
1328
1352
  if (limit) queryParams.append("limit", limit.toString());
1329
- const response = await fetch2(`${API_BASE_URL}/api/logs/analytics/${source}?${queryParams}`, {
1353
+ let response = await fetch2(`${API_BASE_URL}/api/logs/${source}?${queryParams}`, {
1330
1354
  method: "GET",
1331
1355
  headers: {
1332
1356
  "x-api-key": actualApiKey
1333
1357
  }
1334
1358
  });
1359
+ if (response.status === 404) {
1360
+ response = await fetch2(`${API_BASE_URL}/api/logs/analytics/${source}?${queryParams}`, {
1361
+ method: "GET",
1362
+ headers: {
1363
+ "x-api-key": actualApiKey
1364
+ }
1365
+ });
1366
+ }
1335
1367
  const result = await handleApiResponse(response);
1336
- return {
1368
+ return await addBackgroundContext({
1337
1369
  content: [
1338
1370
  {
1339
1371
  type: "text",
1340
1372
  text: formatSuccessMessage(`Latest logs from ${source}`, result)
1341
1373
  }
1342
1374
  ]
1343
- };
1375
+ });
1344
1376
  } catch (error) {
1345
1377
  const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
1346
- return {
1378
+ return await addBackgroundContext({
1347
1379
  content: [
1348
1380
  {
1349
1381
  type: "text",
@@ -1351,7 +1383,7 @@ ${JSON.stringify(metadata, null, 2)}`
1351
1383
  }
1352
1384
  ],
1353
1385
  isError: true
1354
- };
1386
+ });
1355
1387
  }
1356
1388
  })
1357
1389
  );
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  registerInsforgeTools
4
- } from "./chunk-5GCPJFTK.js";
4
+ } from "./chunk-7CREF7XU.js";
5
5
 
6
6
  // src/http/server.ts
7
7
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  registerInsforgeTools
4
- } from "./chunk-5GCPJFTK.js";
4
+ } from "./chunk-7CREF7XU.js";
5
5
 
6
6
  // src/stdio/index.ts
7
7
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@insforge/mcp",
3
- "version": "1.1.5-dev.1",
3
+ "version": "1.1.6",
4
4
  "description": "MCP (Model Context Protocol) server for Insforge backend-as-a-service",
5
+ "mcpName": "io.github.insforge/insforge-mcp",
5
6
  "type": "module",
6
7
  "main": "dist/index.js",
7
8
  "bin": {
@@ -31,7 +32,8 @@
31
32
  },
32
33
  "files": [
33
34
  "dist",
34
- "mcp.json"
35
+ "mcp.json",
36
+ "server.json"
35
37
  ],
36
38
  "dependencies": {
37
39
  "@insforge/shared-schemas": "^1.1.1",
package/server.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-10-17/server.schema.json",
3
+ "name": "io.github.InsForge/insforge-mcp",
4
+ "title": "Insforge",
5
+ "description": "MCP server for Insforge BaaS - database, auth, storage, edge functions, and container logs",
6
+ "version": "1.1.5",
7
+ "packages": [
8
+ {
9
+ "registryType": "npm",
10
+ "identifier": "@insforge/mcp",
11
+ "version": "1.1.5",
12
+ "transport": {
13
+ "type": "stdio"
14
+ }
15
+ }
16
+ ]
17
+ }