open-mcp-app 0.0.13 → 0.0.14

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.
@@ -1,5 +1,6 @@
1
- import { z } from 'zod';
2
1
  import * as express from 'express';
2
+ import express__default from 'express';
3
+ import { z } from 'zod';
3
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
5
  import { CreateMessageRequestParams, CreateMessageResult, CreateMessageResultWithTools } from '@modelcontextprotocol/sdk/types.js';
5
6
 
@@ -614,6 +615,11 @@ declare class App {
614
615
  * Get all resource definitions.
615
616
  */
616
617
  getResourceDefinitions(): Map<string, ResourceDefinition>;
618
+ /**
619
+ * Get the Express application for serverless wrapping (e.g. Lambda).
620
+ * Does NOT start listening on a port.
621
+ */
622
+ toExpressApp(): express__default.Express;
617
623
  /**
618
624
  * Close a specific transport session.
619
625
  */
@@ -786,6 +792,26 @@ declare function htmlLoader(htmlOrPath: string, basePath?: string): () => string
786
792
  */
787
793
  declare function wrapServer<T extends McpServer>(server: T): T;
788
794
 
795
+ /**
796
+ * Storage RPC Client
797
+ *
798
+ * Provides storage operations via RPC to the Creature host.
799
+ * Used by experimental.ts to route KV and blob operations through the host
800
+ * instead of direct file I/O, ensuring consistent behavior for both local
801
+ * and hosted MCPs.
802
+ */
803
+
804
+ interface KvSearchResult {
805
+ key: string;
806
+ snippet?: string;
807
+ score?: number;
808
+ }
809
+ interface VectorSearchResult {
810
+ key: string;
811
+ score: number;
812
+ metadata?: unknown;
813
+ }
814
+
789
815
  /**
790
816
  * Experimental Server APIs
791
817
  *
@@ -801,7 +827,7 @@ declare function wrapServer<T extends McpServer>(server: T): T;
801
827
  * import { exp } from "open-mcp-app/server";
802
828
  *
803
829
  * const dir = exp.getWritableDirectory();
804
- * const content = await exp.readFile("state.json");
830
+ * await exp.kvSet("key", "value");
805
831
  * ```
806
832
  */
807
833
 
@@ -1032,6 +1058,348 @@ declare function experimental_rmdir(relativePath: string): Promise<void>;
1032
1058
  * @throws Error if storage unavailable or path escapes sandbox
1033
1059
  */
1034
1060
  declare function experimental_rmdirSync(relativePath: string): void;
1061
+
1062
+ /**
1063
+ * Check if KV storage is available.
1064
+ *
1065
+ * Returns true if running inside Creature with storage enabled.
1066
+ * Use this to implement graceful fallbacks.
1067
+ *
1068
+ * @returns true if KV storage is available
1069
+ *
1070
+ * @example
1071
+ * ```typescript
1072
+ * import { experimental_kvIsAvailable } from "open-mcp-app/server";
1073
+ *
1074
+ * if (experimental_kvIsAvailable()) {
1075
+ * // Use persistent KV storage
1076
+ * } else {
1077
+ * // Fall back to in-memory storage
1078
+ * }
1079
+ * ```
1080
+ */
1081
+ declare function experimental_kvIsAvailable(): boolean;
1082
+ /**
1083
+ * Get a value from the KV store.
1084
+ *
1085
+ * Uses RPC to communicate with the Creature host for storage operations.
1086
+ * This ensures consistent behavior for both local and hosted MCPs.
1087
+ *
1088
+ * @param key - The key to retrieve
1089
+ * @returns The value, or null if not found or storage unavailable
1090
+ *
1091
+ * @example
1092
+ * ```typescript
1093
+ * import { experimental_kvGet } from "open-mcp-app/server";
1094
+ *
1095
+ * const value = await experimental_kvGet("user:preferences");
1096
+ * if (value) {
1097
+ * const prefs = JSON.parse(value);
1098
+ * }
1099
+ * ```
1100
+ */
1101
+ declare function experimental_kvGet(key: string): Promise<string | null>;
1102
+ /**
1103
+ * Get a value from the KV store synchronously.
1104
+ *
1105
+ * Note: Sync variants are not supported with RPC and will return null.
1106
+ * Use the async version for reliable cross-platform behavior.
1107
+ *
1108
+ * @param key - The key to retrieve
1109
+ * @returns The value, or null if not found or storage unavailable
1110
+ * @deprecated Use experimental_kvGet instead for cross-platform support
1111
+ */
1112
+ declare function experimental_kvGetSync(key: string): string | null;
1113
+ /**
1114
+ * Set a value in the KV store.
1115
+ *
1116
+ * Uses RPC to communicate with the Creature host for storage operations.
1117
+ * This ensures consistent behavior for both local and hosted MCPs.
1118
+ *
1119
+ * @param key - The key to set
1120
+ * @param value - The value to store (string)
1121
+ * @returns true if successful, false if storage unavailable
1122
+ *
1123
+ * @example
1124
+ * ```typescript
1125
+ * import { experimental_kvSet } from "open-mcp-app/server";
1126
+ *
1127
+ * await experimental_kvSet("user:preferences", JSON.stringify(prefs));
1128
+ * ```
1129
+ */
1130
+ declare function experimental_kvSet(key: string, value: string): Promise<boolean>;
1131
+ /**
1132
+ * Set a value in the KV store synchronously.
1133
+ *
1134
+ * Note: Sync variants are not supported with RPC and will return false.
1135
+ * Use the async version for reliable cross-platform behavior.
1136
+ *
1137
+ * @param key - The key to set
1138
+ * @param value - The value to store (string)
1139
+ * @returns true if successful, false if storage unavailable
1140
+ * @deprecated Use experimental_kvSet instead for cross-platform support
1141
+ */
1142
+ declare function experimental_kvSetSync(key: string, value: string): boolean;
1143
+ /**
1144
+ * Delete a key from the KV store.
1145
+ *
1146
+ * Uses RPC to communicate with the Creature host for storage operations.
1147
+ * This ensures consistent behavior for both local and hosted MCPs.
1148
+ *
1149
+ * @param key - The key to delete
1150
+ * @returns true if the key existed and was deleted, false otherwise
1151
+ *
1152
+ * @example
1153
+ * ```typescript
1154
+ * import { experimental_kvDelete } from "open-mcp-app/server";
1155
+ *
1156
+ * const deleted = await experimental_kvDelete("user:preferences");
1157
+ * ```
1158
+ */
1159
+ declare function experimental_kvDelete(key: string): Promise<boolean>;
1160
+ /**
1161
+ * Delete a key from the KV store synchronously.
1162
+ *
1163
+ * Note: Sync variants are not supported with RPC and will return false.
1164
+ * Use the async version for reliable cross-platform behavior.
1165
+ *
1166
+ * @param key - The key to delete
1167
+ * @returns true if the key existed and was deleted, false otherwise
1168
+ * @deprecated Use experimental_kvDelete instead for cross-platform support
1169
+ */
1170
+ declare function experimental_kvDeleteSync(key: string): boolean;
1171
+ /**
1172
+ * List keys in the KV store.
1173
+ *
1174
+ * Uses RPC to communicate with the Creature host for storage operations.
1175
+ * This ensures consistent behavior for both local and hosted MCPs.
1176
+ *
1177
+ * @param prefix - Optional prefix to filter keys
1178
+ * @returns Array of matching keys, or null if storage unavailable
1179
+ *
1180
+ * @example
1181
+ * ```typescript
1182
+ * import { experimental_kvList } from "open-mcp-app/server";
1183
+ *
1184
+ * const userKeys = await experimental_kvList("user:");
1185
+ * ```
1186
+ */
1187
+ declare function experimental_kvList(prefix?: string): Promise<string[] | null>;
1188
+ /**
1189
+ * List key-value pairs from the KV store.
1190
+ *
1191
+ * This is more efficient than calling kvList + kvGet for each key,
1192
+ * as it fetches all data in a single RPC call.
1193
+ *
1194
+ * @param prefix - Optional prefix to filter keys
1195
+ * @returns Array of key-value pairs, or null if storage unavailable
1196
+ *
1197
+ * @example
1198
+ * ```typescript
1199
+ * import { exp } from "open-mcp-app/server";
1200
+ *
1201
+ * const entries = await exp.kvListWithValues("todos:");
1202
+ * for (const { key, value } of entries ?? []) {
1203
+ * console.log(key, JSON.parse(value));
1204
+ * }
1205
+ * ```
1206
+ */
1207
+ declare function experimental_kvListWithValues(prefix?: string): Promise<Array<{
1208
+ key: string;
1209
+ value: string;
1210
+ }> | null>;
1211
+ /**
1212
+ * List keys in the KV store synchronously.
1213
+ *
1214
+ * Note: Sync variants are not supported with RPC and will return null.
1215
+ * Use the async version for reliable cross-platform behavior.
1216
+ *
1217
+ * @param prefix - Optional prefix to filter keys
1218
+ * @returns Array of matching keys, or null if storage unavailable
1219
+ * @deprecated Use experimental_kvList instead for cross-platform support
1220
+ */
1221
+ declare function experimental_kvListSync(prefix?: string): string[] | null;
1222
+ /**
1223
+ * Search values in the KV store using full-text search.
1224
+ *
1225
+ * Uses SQLite FTS5 on the Creature host for efficient full-text search.
1226
+ * Returns results ranked by relevance with optional snippets.
1227
+ *
1228
+ * @param query - The search query (uses SQLite FTS5 syntax)
1229
+ * @param options - Search options
1230
+ * @param options.prefix - Optional key prefix to filter results
1231
+ * @param options.limit - Maximum number of results (default 50, max 100)
1232
+ * @returns Array of search results, or null if storage unavailable
1233
+ *
1234
+ * @example
1235
+ * ```typescript
1236
+ * import { experimental_kvSearch } from "open-mcp-app/server";
1237
+ *
1238
+ * // Search for notes containing "meeting"
1239
+ * const results = await experimental_kvSearch("meeting");
1240
+ *
1241
+ * // Search with prefix filter
1242
+ * const todoResults = await experimental_kvSearch("urgent", { prefix: "todos:" });
1243
+ *
1244
+ * for (const result of results ?? []) {
1245
+ * console.log(result.key, result.snippet, result.score);
1246
+ * }
1247
+ * ```
1248
+ */
1249
+ declare function experimental_kvSearch(query: string, options?: {
1250
+ prefix?: string;
1251
+ limit?: number;
1252
+ }): Promise<KvSearchResult[] | null>;
1253
+ declare function experimental_vectorIsAvailable(): boolean;
1254
+ declare function experimental_vectorUpsert(key: string, text: string, metadata?: unknown): Promise<boolean>;
1255
+ declare function experimental_vectorSearch(query: string, options?: {
1256
+ prefix?: string;
1257
+ limit?: number;
1258
+ }): Promise<VectorSearchResult[] | null>;
1259
+ declare function experimental_vectorDelete(key: string): Promise<boolean>;
1260
+
1261
+ /**
1262
+ * Check if blob storage is available.
1263
+ *
1264
+ * Returns true if running inside Creature with storage enabled.
1265
+ * Use this to implement graceful fallbacks.
1266
+ *
1267
+ * @returns true if blob storage is available
1268
+ */
1269
+ declare function experimental_blobIsAvailable(): boolean;
1270
+ /**
1271
+ * Store a blob.
1272
+ *
1273
+ * Uses RPC to communicate with the Creature host for storage operations.
1274
+ * This ensures consistent behavior for both local and hosted MCPs.
1275
+ *
1276
+ * @param name - The blob name (acts as a path within the blobs directory)
1277
+ * @param data - The blob data as a Buffer or Uint8Array
1278
+ * @param mimeType - Optional MIME type metadata
1279
+ * @returns Object with success and size, or null if storage unavailable
1280
+ *
1281
+ * @example
1282
+ * ```typescript
1283
+ * import { experimental_blobPut } from "open-mcp-app/server";
1284
+ *
1285
+ * const imageData = fs.readFileSync("image.png");
1286
+ * await experimental_blobPut("images/photo.png", imageData, "image/png");
1287
+ * ```
1288
+ */
1289
+ declare function experimental_blobPut(name: string, data: Buffer | Uint8Array, mimeType?: string): Promise<{
1290
+ success: true;
1291
+ size: number;
1292
+ } | null>;
1293
+ /**
1294
+ * Store a blob synchronously.
1295
+ *
1296
+ * Note: Sync variants are not supported with RPC and will return null.
1297
+ * Use the async version for reliable cross-platform behavior.
1298
+ *
1299
+ * @param name - The blob name
1300
+ * @param data - The blob data
1301
+ * @param mimeType - Optional MIME type metadata
1302
+ * @returns Object with success and size, or null if storage unavailable
1303
+ * @deprecated Use experimental_blobPut instead for cross-platform support
1304
+ */
1305
+ declare function experimental_blobPutSync(name: string, data: Buffer | Uint8Array, mimeType?: string): {
1306
+ success: true;
1307
+ size: number;
1308
+ } | null;
1309
+ /**
1310
+ * Retrieve a blob.
1311
+ *
1312
+ * Uses RPC to communicate with the Creature host for storage operations.
1313
+ * This ensures consistent behavior for both local and hosted MCPs.
1314
+ *
1315
+ * @param name - The blob name
1316
+ * @returns Object with data and optional mimeType, or null if not found
1317
+ *
1318
+ * @example
1319
+ * ```typescript
1320
+ * import { experimental_blobGet } from "open-mcp-app/server";
1321
+ *
1322
+ * const result = await experimental_blobGet("images/photo.png");
1323
+ * if (result) {
1324
+ * // result.data is a Buffer
1325
+ * // result.mimeType is optional string
1326
+ * }
1327
+ * ```
1328
+ */
1329
+ declare function experimental_blobGet(name: string): Promise<{
1330
+ data: Buffer;
1331
+ mimeType?: string;
1332
+ } | null>;
1333
+ /**
1334
+ * Retrieve a blob synchronously.
1335
+ *
1336
+ * Note: Sync variants are not supported with RPC and will return null.
1337
+ * Use the async version for reliable cross-platform behavior.
1338
+ *
1339
+ * @param name - The blob name
1340
+ * @returns Object with data and optional mimeType, or null if not found
1341
+ * @deprecated Use experimental_blobGet instead for cross-platform support
1342
+ */
1343
+ declare function experimental_blobGetSync(name: string): {
1344
+ data: Buffer;
1345
+ mimeType?: string;
1346
+ } | null;
1347
+ /**
1348
+ * Delete a blob.
1349
+ *
1350
+ * Uses RPC to communicate with the Creature host for storage operations.
1351
+ * This ensures consistent behavior for both local and hosted MCPs.
1352
+ *
1353
+ * @param name - The blob name
1354
+ * @returns true if deleted, false if not found or storage unavailable
1355
+ *
1356
+ * @example
1357
+ * ```typescript
1358
+ * import { experimental_blobDelete } from "open-mcp-app/server";
1359
+ *
1360
+ * await experimental_blobDelete("images/old-photo.png");
1361
+ * ```
1362
+ */
1363
+ declare function experimental_blobDelete(name: string): Promise<boolean>;
1364
+ /**
1365
+ * Delete a blob synchronously.
1366
+ *
1367
+ * Note: Sync variants are not supported with RPC and will return false.
1368
+ * Use the async version for reliable cross-platform behavior.
1369
+ *
1370
+ * @param name - The blob name
1371
+ * @returns true if deleted, false if not found or storage unavailable
1372
+ * @deprecated Use experimental_blobDelete instead for cross-platform support
1373
+ */
1374
+ declare function experimental_blobDeleteSync(name: string): boolean;
1375
+ /**
1376
+ * List blobs.
1377
+ *
1378
+ * Uses RPC to communicate with the Creature host for storage operations.
1379
+ * This ensures consistent behavior for both local and hosted MCPs.
1380
+ *
1381
+ * @param prefix - Optional prefix to filter blob names
1382
+ * @returns Array of blob names, or null if storage unavailable
1383
+ *
1384
+ * @example
1385
+ * ```typescript
1386
+ * import { experimental_blobList } from "open-mcp-app/server";
1387
+ *
1388
+ * const images = await experimental_blobList("images/");
1389
+ * ```
1390
+ */
1391
+ declare function experimental_blobList(prefix?: string): Promise<string[] | null>;
1392
+ /**
1393
+ * List blobs synchronously.
1394
+ *
1395
+ * Note: Sync variants are not supported with RPC and will return null.
1396
+ * Use the async version for reliable cross-platform behavior.
1397
+ *
1398
+ * @param prefix - Optional prefix to filter blob names
1399
+ * @returns Array of blob names, or null if storage unavailable
1400
+ * @deprecated Use experimental_blobList instead for cross-platform support
1401
+ */
1402
+ declare function experimental_blobListSync(prefix?: string): string[] | null;
1035
1403
  declare function experimental_sampleMessage(params: CreateMessageRequestParams): Promise<CreateMessageResult | CreateMessageResultWithTools>;
1036
1404
  /**
1037
1405
  * Experimental APIs namespace.
@@ -1044,7 +1412,13 @@ declare function experimental_sampleMessage(params: CreateMessageRequestParams):
1044
1412
  * import { exp } from "open-mcp-app/server";
1045
1413
  *
1046
1414
  * // Environment
1047
- * const dir = exp.getWritableDirectory();
1415
+ * if (exp.isCreatureHost()) {
1416
+ * const dir = exp.getWritableDirectory();
1417
+ * }
1418
+ *
1419
+ * // KV Store
1420
+ * await exp.kvSet("user:prefs", JSON.stringify(prefs));
1421
+ * const value = await exp.kvGet("user:prefs");
1048
1422
  *
1049
1423
  * // File I/O
1050
1424
  * await exp.writeFile("config.json", JSON.stringify(config));
@@ -1069,7 +1443,39 @@ declare const exp: {
1069
1443
  mkdirSync: typeof experimental_mkdirSync;
1070
1444
  readdirSync: typeof experimental_readdirSync;
1071
1445
  rmdirSync: typeof experimental_rmdirSync;
1446
+ kvIsAvailable: typeof experimental_kvIsAvailable;
1447
+ kvGet: typeof experimental_kvGet;
1448
+ kvSet: typeof experimental_kvSet;
1449
+ kvDelete: typeof experimental_kvDelete;
1450
+ kvList: typeof experimental_kvList;
1451
+ kvListWithValues: typeof experimental_kvListWithValues;
1452
+ kvSearch: typeof experimental_kvSearch;
1453
+ vectorIsAvailable: typeof experimental_vectorIsAvailable;
1454
+ vectorUpsert: typeof experimental_vectorUpsert;
1455
+ vectorSearch: typeof experimental_vectorSearch;
1456
+ vectorDelete: typeof experimental_vectorDelete;
1457
+ /** @deprecated Use kvGet instead */
1458
+ kvGetSync: typeof experimental_kvGetSync;
1459
+ /** @deprecated Use kvSet instead */
1460
+ kvSetSync: typeof experimental_kvSetSync;
1461
+ /** @deprecated Use kvDelete instead */
1462
+ kvDeleteSync: typeof experimental_kvDeleteSync;
1463
+ /** @deprecated Use kvList instead */
1464
+ kvListSync: typeof experimental_kvListSync;
1465
+ blobIsAvailable: typeof experimental_blobIsAvailable;
1466
+ blobPut: typeof experimental_blobPut;
1467
+ blobGet: typeof experimental_blobGet;
1468
+ blobDelete: typeof experimental_blobDelete;
1469
+ blobList: typeof experimental_blobList;
1470
+ /** @deprecated Use blobPut instead */
1471
+ blobPutSync: typeof experimental_blobPutSync;
1472
+ /** @deprecated Use blobGet instead */
1473
+ blobGetSync: typeof experimental_blobGetSync;
1474
+ /** @deprecated Use blobDelete instead */
1475
+ blobDeleteSync: typeof experimental_blobDeleteSync;
1476
+ /** @deprecated Use blobList instead */
1477
+ blobListSync: typeof experimental_blobListSync;
1072
1478
  sampleMessage: typeof experimental_sampleMessage;
1073
1479
  };
1074
1480
 
1075
- export { App, type AppConfig, type DisplayMode, type IconConfig, type InstanceDestroyContext, MIME_TYPES, type ResourceConfig, type ServerLogLevel, type ServerLogger, type ToolAnnotations, type ToolCallInfo, type ToolCallResultInfo, type ToolConfig, type ToolContext, type ToolHandler, type ToolResult, type ToolVisibility, type TransportSessionInfo, type TransportType, type WebSocketConnection, createApp, exp, experimental_deleteFile, experimental_deleteFileSync, experimental_exists, experimental_existsSync, experimental_getProjectId, experimental_getServerName, experimental_getWritableDirectory, experimental_mkdir, experimental_mkdirSync, experimental_readFile, experimental_readFileSync, experimental_readdir, experimental_readdirSync, experimental_rmdir, experimental_rmdirSync, experimental_sampleMessage, experimental_writeFile, experimental_writeFileSync, htmlLoader, isHtmlContent, loadHtml, svgToDataUri, wrapServer };
1481
+ export { App, type AppConfig, type DisplayMode, type IconConfig, type InstanceDestroyContext, type KvSearchResult, MIME_TYPES, type ResourceConfig, type ServerLogLevel, type ServerLogger, type ToolAnnotations, type ToolCallInfo, type ToolCallResultInfo, type ToolConfig, type ToolContext, type ToolHandler, type ToolResult, type ToolVisibility, type TransportSessionInfo, type TransportType, type VectorSearchResult, type WebSocketConnection, createApp, exp, experimental_blobDelete, experimental_blobDeleteSync, experimental_blobGet, experimental_blobGetSync, experimental_blobIsAvailable, experimental_blobList, experimental_blobListSync, experimental_blobPut, experimental_blobPutSync, experimental_deleteFile, experimental_deleteFileSync, experimental_exists, experimental_existsSync, experimental_getProjectId, experimental_getServerName, experimental_getWritableDirectory, experimental_kvDelete, experimental_kvDeleteSync, experimental_kvGet, experimental_kvGetSync, experimental_kvIsAvailable, experimental_kvList, experimental_kvListSync, experimental_kvSearch, experimental_kvSet, experimental_kvSetSync, experimental_mkdir, experimental_mkdirSync, experimental_readFile, experimental_readFileSync, experimental_readdir, experimental_readdirSync, experimental_rmdir, experimental_rmdirSync, experimental_sampleMessage, experimental_vectorDelete, experimental_vectorIsAvailable, experimental_vectorSearch, experimental_vectorUpsert, experimental_writeFile, experimental_writeFileSync, htmlLoader, isHtmlContent, loadHtml, svgToDataUri, wrapServer };