open-mcp-app 0.0.11 → 0.0.13

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.
@@ -176,11 +176,24 @@ interface ToolExperimentalConfig {
176
176
  * Note: defaultDisplayMode is a Creature extension. Not part of MCP Apps spec.
177
177
  */
178
178
  defaultDisplayMode?: DisplayMode;
179
- /**
180
- * Whether a new pip should open in background when another pip is already active.
181
- * Note: openInBackground is a Creature extension.
182
- */
183
- openInBackground?: boolean;
179
+ }
180
+ /**
181
+ * MCP tool annotations.
182
+ *
183
+ * Hints that describe tool behavior without affecting protocol semantics.
184
+ * Hosts use these to make UI/UX decisions (e.g. confirmation prompts).
185
+ */
186
+ interface ToolAnnotations {
187
+ /** Human-readable title for the tool. */
188
+ title?: string;
189
+ /** If true, the tool does not modify any state (default: false). */
190
+ readOnlyHint?: boolean;
191
+ /** If true, the tool may perform destructive/irreversible operations (default: true). */
192
+ destructiveHint?: boolean;
193
+ /** If true, calling the tool repeatedly with the same args has no additional effect (default: false). */
194
+ idempotentHint?: boolean;
195
+ /** If true, the tool may interact with the world outside the MCP server (default: true). */
196
+ openWorldHint?: boolean;
184
197
  }
185
198
  /**
186
199
  * Tool configuration.
@@ -196,6 +209,8 @@ interface ToolConfig<TInput extends z.ZodType = z.ZodType> {
196
209
  visibility?: ToolVisibility[];
197
210
  /** Supported display modes for this tool */
198
211
  displayModes?: DisplayMode[];
212
+ /** MCP tool annotations (readOnlyHint, destructiveHint, etc.) */
213
+ annotations?: ToolAnnotations;
199
214
  /** Loading message shown while tool is running (used by ChatGPT) */
200
215
  loadingMessage?: string;
201
216
  /** Completion message shown when tool finishes (used by ChatGPT) */
@@ -328,6 +343,12 @@ interface AppConfig {
328
343
  port?: number;
329
344
  /** Enable dev mode (default: auto-detect from NODE_ENV) */
330
345
  dev?: boolean;
346
+ /**
347
+ * Enable built-in CORS headers (default: true).
348
+ * Set to `false` when behind a reverse proxy that handles CORS
349
+ * to avoid duplicate Access-Control-Allow-Origin headers.
350
+ */
351
+ cors?: boolean;
331
352
  /**
332
353
  * Called when a new transport session is created.
333
354
  * Transport sessions are MCP protocol connections (not instances).
@@ -765,26 +786,6 @@ declare function htmlLoader(htmlOrPath: string, basePath?: string): () => string
765
786
  */
766
787
  declare function wrapServer<T extends McpServer>(server: T): T;
767
788
 
768
- /**
769
- * Storage RPC Client
770
- *
771
- * Provides storage operations via RPC to the Creature host.
772
- * Used by experimental.ts to route KV and blob operations through the host
773
- * instead of direct file I/O, ensuring consistent behavior for both local
774
- * and hosted MCPs.
775
- */
776
-
777
- interface KvSearchResult {
778
- key: string;
779
- snippet?: string;
780
- score?: number;
781
- }
782
- interface VectorSearchResult {
783
- key: string;
784
- score: number;
785
- metadata?: unknown;
786
- }
787
-
788
789
  /**
789
790
  * Experimental Server APIs
790
791
  *
@@ -800,7 +801,7 @@ interface VectorSearchResult {
800
801
  * import { exp } from "open-mcp-app/server";
801
802
  *
802
803
  * const dir = exp.getWritableDirectory();
803
- * await exp.kvSet("key", "value");
804
+ * const content = await exp.readFile("state.json");
804
805
  * ```
805
806
  */
806
807
 
@@ -1031,348 +1032,6 @@ declare function experimental_rmdir(relativePath: string): Promise<void>;
1031
1032
  * @throws Error if storage unavailable or path escapes sandbox
1032
1033
  */
1033
1034
  declare function experimental_rmdirSync(relativePath: string): void;
1034
-
1035
- /**
1036
- * Check if KV storage is available.
1037
- *
1038
- * Returns true if running inside Creature with storage enabled.
1039
- * Use this to implement graceful fallbacks.
1040
- *
1041
- * @returns true if KV storage is available
1042
- *
1043
- * @example
1044
- * ```typescript
1045
- * import { experimental_kvIsAvailable } from "open-mcp-app/server";
1046
- *
1047
- * if (experimental_kvIsAvailable()) {
1048
- * // Use persistent KV storage
1049
- * } else {
1050
- * // Fall back to in-memory storage
1051
- * }
1052
- * ```
1053
- */
1054
- declare function experimental_kvIsAvailable(): boolean;
1055
- /**
1056
- * Get a value from the KV store.
1057
- *
1058
- * Uses RPC to communicate with the Creature host for storage operations.
1059
- * This ensures consistent behavior for both local and hosted MCPs.
1060
- *
1061
- * @param key - The key to retrieve
1062
- * @returns The value, or null if not found or storage unavailable
1063
- *
1064
- * @example
1065
- * ```typescript
1066
- * import { experimental_kvGet } from "open-mcp-app/server";
1067
- *
1068
- * const value = await experimental_kvGet("user:preferences");
1069
- * if (value) {
1070
- * const prefs = JSON.parse(value);
1071
- * }
1072
- * ```
1073
- */
1074
- declare function experimental_kvGet(key: string): Promise<string | null>;
1075
- /**
1076
- * Get a value from the KV store synchronously.
1077
- *
1078
- * Note: Sync variants are not supported with RPC and will return null.
1079
- * Use the async version for reliable cross-platform behavior.
1080
- *
1081
- * @param key - The key to retrieve
1082
- * @returns The value, or null if not found or storage unavailable
1083
- * @deprecated Use experimental_kvGet instead for cross-platform support
1084
- */
1085
- declare function experimental_kvGetSync(key: string): string | null;
1086
- /**
1087
- * Set a value in the KV store.
1088
- *
1089
- * Uses RPC to communicate with the Creature host for storage operations.
1090
- * This ensures consistent behavior for both local and hosted MCPs.
1091
- *
1092
- * @param key - The key to set
1093
- * @param value - The value to store (string)
1094
- * @returns true if successful, false if storage unavailable
1095
- *
1096
- * @example
1097
- * ```typescript
1098
- * import { experimental_kvSet } from "open-mcp-app/server";
1099
- *
1100
- * await experimental_kvSet("user:preferences", JSON.stringify(prefs));
1101
- * ```
1102
- */
1103
- declare function experimental_kvSet(key: string, value: string): Promise<boolean>;
1104
- /**
1105
- * Set a value in the KV store synchronously.
1106
- *
1107
- * Note: Sync variants are not supported with RPC and will return false.
1108
- * Use the async version for reliable cross-platform behavior.
1109
- *
1110
- * @param key - The key to set
1111
- * @param value - The value to store (string)
1112
- * @returns true if successful, false if storage unavailable
1113
- * @deprecated Use experimental_kvSet instead for cross-platform support
1114
- */
1115
- declare function experimental_kvSetSync(key: string, value: string): boolean;
1116
- /**
1117
- * Delete a key from the KV store.
1118
- *
1119
- * Uses RPC to communicate with the Creature host for storage operations.
1120
- * This ensures consistent behavior for both local and hosted MCPs.
1121
- *
1122
- * @param key - The key to delete
1123
- * @returns true if the key existed and was deleted, false otherwise
1124
- *
1125
- * @example
1126
- * ```typescript
1127
- * import { experimental_kvDelete } from "open-mcp-app/server";
1128
- *
1129
- * const deleted = await experimental_kvDelete("user:preferences");
1130
- * ```
1131
- */
1132
- declare function experimental_kvDelete(key: string): Promise<boolean>;
1133
- /**
1134
- * Delete a key from the KV store synchronously.
1135
- *
1136
- * Note: Sync variants are not supported with RPC and will return false.
1137
- * Use the async version for reliable cross-platform behavior.
1138
- *
1139
- * @param key - The key to delete
1140
- * @returns true if the key existed and was deleted, false otherwise
1141
- * @deprecated Use experimental_kvDelete instead for cross-platform support
1142
- */
1143
- declare function experimental_kvDeleteSync(key: string): boolean;
1144
- /**
1145
- * List keys in the KV store.
1146
- *
1147
- * Uses RPC to communicate with the Creature host for storage operations.
1148
- * This ensures consistent behavior for both local and hosted MCPs.
1149
- *
1150
- * @param prefix - Optional prefix to filter keys
1151
- * @returns Array of matching keys, or null if storage unavailable
1152
- *
1153
- * @example
1154
- * ```typescript
1155
- * import { experimental_kvList } from "open-mcp-app/server";
1156
- *
1157
- * const userKeys = await experimental_kvList("user:");
1158
- * ```
1159
- */
1160
- declare function experimental_kvList(prefix?: string): Promise<string[] | null>;
1161
- /**
1162
- * List key-value pairs from the KV store.
1163
- *
1164
- * This is more efficient than calling kvList + kvGet for each key,
1165
- * as it fetches all data in a single RPC call.
1166
- *
1167
- * @param prefix - Optional prefix to filter keys
1168
- * @returns Array of key-value pairs, or null if storage unavailable
1169
- *
1170
- * @example
1171
- * ```typescript
1172
- * import { exp } from "open-mcp-app/server";
1173
- *
1174
- * const entries = await exp.kvListWithValues("todos:");
1175
- * for (const { key, value } of entries ?? []) {
1176
- * console.log(key, JSON.parse(value));
1177
- * }
1178
- * ```
1179
- */
1180
- declare function experimental_kvListWithValues(prefix?: string): Promise<Array<{
1181
- key: string;
1182
- value: string;
1183
- }> | null>;
1184
- /**
1185
- * List keys in the KV store synchronously.
1186
- *
1187
- * Note: Sync variants are not supported with RPC and will return null.
1188
- * Use the async version for reliable cross-platform behavior.
1189
- *
1190
- * @param prefix - Optional prefix to filter keys
1191
- * @returns Array of matching keys, or null if storage unavailable
1192
- * @deprecated Use experimental_kvList instead for cross-platform support
1193
- */
1194
- declare function experimental_kvListSync(prefix?: string): string[] | null;
1195
- /**
1196
- * Search values in the KV store using full-text search.
1197
- *
1198
- * Uses SQLite FTS5 on the Creature host for efficient full-text search.
1199
- * Returns results ranked by relevance with optional snippets.
1200
- *
1201
- * @param query - The search query (uses SQLite FTS5 syntax)
1202
- * @param options - Search options
1203
- * @param options.prefix - Optional key prefix to filter results
1204
- * @param options.limit - Maximum number of results (default 50, max 100)
1205
- * @returns Array of search results, or null if storage unavailable
1206
- *
1207
- * @example
1208
- * ```typescript
1209
- * import { experimental_kvSearch } from "open-mcp-app/server";
1210
- *
1211
- * // Search for notes containing "meeting"
1212
- * const results = await experimental_kvSearch("meeting");
1213
- *
1214
- * // Search with prefix filter
1215
- * const todoResults = await experimental_kvSearch("urgent", { prefix: "todos:" });
1216
- *
1217
- * for (const result of results ?? []) {
1218
- * console.log(result.key, result.snippet, result.score);
1219
- * }
1220
- * ```
1221
- */
1222
- declare function experimental_kvSearch(query: string, options?: {
1223
- prefix?: string;
1224
- limit?: number;
1225
- }): Promise<KvSearchResult[] | null>;
1226
- declare function experimental_vectorIsAvailable(): boolean;
1227
- declare function experimental_vectorUpsert(key: string, text: string, metadata?: unknown): Promise<boolean>;
1228
- declare function experimental_vectorSearch(query: string, options?: {
1229
- prefix?: string;
1230
- limit?: number;
1231
- }): Promise<VectorSearchResult[] | null>;
1232
- declare function experimental_vectorDelete(key: string): Promise<boolean>;
1233
-
1234
- /**
1235
- * Check if blob storage is available.
1236
- *
1237
- * Returns true if running inside Creature with storage enabled.
1238
- * Use this to implement graceful fallbacks.
1239
- *
1240
- * @returns true if blob storage is available
1241
- */
1242
- declare function experimental_blobIsAvailable(): boolean;
1243
- /**
1244
- * Store a blob.
1245
- *
1246
- * Uses RPC to communicate with the Creature host for storage operations.
1247
- * This ensures consistent behavior for both local and hosted MCPs.
1248
- *
1249
- * @param name - The blob name (acts as a path within the blobs directory)
1250
- * @param data - The blob data as a Buffer or Uint8Array
1251
- * @param mimeType - Optional MIME type metadata
1252
- * @returns Object with success and size, or null if storage unavailable
1253
- *
1254
- * @example
1255
- * ```typescript
1256
- * import { experimental_blobPut } from "open-mcp-app/server";
1257
- *
1258
- * const imageData = fs.readFileSync("image.png");
1259
- * await experimental_blobPut("images/photo.png", imageData, "image/png");
1260
- * ```
1261
- */
1262
- declare function experimental_blobPut(name: string, data: Buffer | Uint8Array, mimeType?: string): Promise<{
1263
- success: true;
1264
- size: number;
1265
- } | null>;
1266
- /**
1267
- * Store a blob synchronously.
1268
- *
1269
- * Note: Sync variants are not supported with RPC and will return null.
1270
- * Use the async version for reliable cross-platform behavior.
1271
- *
1272
- * @param name - The blob name
1273
- * @param data - The blob data
1274
- * @param mimeType - Optional MIME type metadata
1275
- * @returns Object with success and size, or null if storage unavailable
1276
- * @deprecated Use experimental_blobPut instead for cross-platform support
1277
- */
1278
- declare function experimental_blobPutSync(name: string, data: Buffer | Uint8Array, mimeType?: string): {
1279
- success: true;
1280
- size: number;
1281
- } | null;
1282
- /**
1283
- * Retrieve a blob.
1284
- *
1285
- * Uses RPC to communicate with the Creature host for storage operations.
1286
- * This ensures consistent behavior for both local and hosted MCPs.
1287
- *
1288
- * @param name - The blob name
1289
- * @returns Object with data and optional mimeType, or null if not found
1290
- *
1291
- * @example
1292
- * ```typescript
1293
- * import { experimental_blobGet } from "open-mcp-app/server";
1294
- *
1295
- * const result = await experimental_blobGet("images/photo.png");
1296
- * if (result) {
1297
- * // result.data is a Buffer
1298
- * // result.mimeType is optional string
1299
- * }
1300
- * ```
1301
- */
1302
- declare function experimental_blobGet(name: string): Promise<{
1303
- data: Buffer;
1304
- mimeType?: string;
1305
- } | null>;
1306
- /**
1307
- * Retrieve a blob synchronously.
1308
- *
1309
- * Note: Sync variants are not supported with RPC and will return null.
1310
- * Use the async version for reliable cross-platform behavior.
1311
- *
1312
- * @param name - The blob name
1313
- * @returns Object with data and optional mimeType, or null if not found
1314
- * @deprecated Use experimental_blobGet instead for cross-platform support
1315
- */
1316
- declare function experimental_blobGetSync(name: string): {
1317
- data: Buffer;
1318
- mimeType?: string;
1319
- } | null;
1320
- /**
1321
- * Delete a blob.
1322
- *
1323
- * Uses RPC to communicate with the Creature host for storage operations.
1324
- * This ensures consistent behavior for both local and hosted MCPs.
1325
- *
1326
- * @param name - The blob name
1327
- * @returns true if deleted, false if not found or storage unavailable
1328
- *
1329
- * @example
1330
- * ```typescript
1331
- * import { experimental_blobDelete } from "open-mcp-app/server";
1332
- *
1333
- * await experimental_blobDelete("images/old-photo.png");
1334
- * ```
1335
- */
1336
- declare function experimental_blobDelete(name: string): Promise<boolean>;
1337
- /**
1338
- * Delete a blob synchronously.
1339
- *
1340
- * Note: Sync variants are not supported with RPC and will return false.
1341
- * Use the async version for reliable cross-platform behavior.
1342
- *
1343
- * @param name - The blob name
1344
- * @returns true if deleted, false if not found or storage unavailable
1345
- * @deprecated Use experimental_blobDelete instead for cross-platform support
1346
- */
1347
- declare function experimental_blobDeleteSync(name: string): boolean;
1348
- /**
1349
- * List blobs.
1350
- *
1351
- * Uses RPC to communicate with the Creature host for storage operations.
1352
- * This ensures consistent behavior for both local and hosted MCPs.
1353
- *
1354
- * @param prefix - Optional prefix to filter blob names
1355
- * @returns Array of blob names, or null if storage unavailable
1356
- *
1357
- * @example
1358
- * ```typescript
1359
- * import { experimental_blobList } from "open-mcp-app/server";
1360
- *
1361
- * const images = await experimental_blobList("images/");
1362
- * ```
1363
- */
1364
- declare function experimental_blobList(prefix?: string): Promise<string[] | null>;
1365
- /**
1366
- * List blobs synchronously.
1367
- *
1368
- * Note: Sync variants are not supported with RPC and will return null.
1369
- * Use the async version for reliable cross-platform behavior.
1370
- *
1371
- * @param prefix - Optional prefix to filter blob names
1372
- * @returns Array of blob names, or null if storage unavailable
1373
- * @deprecated Use experimental_blobList instead for cross-platform support
1374
- */
1375
- declare function experimental_blobListSync(prefix?: string): string[] | null;
1376
1035
  declare function experimental_sampleMessage(params: CreateMessageRequestParams): Promise<CreateMessageResult | CreateMessageResultWithTools>;
1377
1036
  /**
1378
1037
  * Experimental APIs namespace.
@@ -1385,13 +1044,7 @@ declare function experimental_sampleMessage(params: CreateMessageRequestParams):
1385
1044
  * import { exp } from "open-mcp-app/server";
1386
1045
  *
1387
1046
  * // Environment
1388
- * if (exp.isCreatureHost()) {
1389
- * const dir = exp.getWritableDirectory();
1390
- * }
1391
- *
1392
- * // KV Store
1393
- * await exp.kvSet("user:prefs", JSON.stringify(prefs));
1394
- * const value = await exp.kvGet("user:prefs");
1047
+ * const dir = exp.getWritableDirectory();
1395
1048
  *
1396
1049
  * // File I/O
1397
1050
  * await exp.writeFile("config.json", JSON.stringify(config));
@@ -1416,39 +1069,7 @@ declare const exp: {
1416
1069
  mkdirSync: typeof experimental_mkdirSync;
1417
1070
  readdirSync: typeof experimental_readdirSync;
1418
1071
  rmdirSync: typeof experimental_rmdirSync;
1419
- kvIsAvailable: typeof experimental_kvIsAvailable;
1420
- kvGet: typeof experimental_kvGet;
1421
- kvSet: typeof experimental_kvSet;
1422
- kvDelete: typeof experimental_kvDelete;
1423
- kvList: typeof experimental_kvList;
1424
- kvListWithValues: typeof experimental_kvListWithValues;
1425
- kvSearch: typeof experimental_kvSearch;
1426
- vectorIsAvailable: typeof experimental_vectorIsAvailable;
1427
- vectorUpsert: typeof experimental_vectorUpsert;
1428
- vectorSearch: typeof experimental_vectorSearch;
1429
- vectorDelete: typeof experimental_vectorDelete;
1430
- /** @deprecated Use kvGet instead */
1431
- kvGetSync: typeof experimental_kvGetSync;
1432
- /** @deprecated Use kvSet instead */
1433
- kvSetSync: typeof experimental_kvSetSync;
1434
- /** @deprecated Use kvDelete instead */
1435
- kvDeleteSync: typeof experimental_kvDeleteSync;
1436
- /** @deprecated Use kvList instead */
1437
- kvListSync: typeof experimental_kvListSync;
1438
- blobIsAvailable: typeof experimental_blobIsAvailable;
1439
- blobPut: typeof experimental_blobPut;
1440
- blobGet: typeof experimental_blobGet;
1441
- blobDelete: typeof experimental_blobDelete;
1442
- blobList: typeof experimental_blobList;
1443
- /** @deprecated Use blobPut instead */
1444
- blobPutSync: typeof experimental_blobPutSync;
1445
- /** @deprecated Use blobGet instead */
1446
- blobGetSync: typeof experimental_blobGetSync;
1447
- /** @deprecated Use blobDelete instead */
1448
- blobDeleteSync: typeof experimental_blobDeleteSync;
1449
- /** @deprecated Use blobList instead */
1450
- blobListSync: typeof experimental_blobListSync;
1451
1072
  sampleMessage: typeof experimental_sampleMessage;
1452
1073
  };
1453
1074
 
1454
- export { App, type AppConfig, type DisplayMode, type IconConfig, type InstanceDestroyContext, type KvSearchResult, MIME_TYPES, type ResourceConfig, type ServerLogLevel, type ServerLogger, 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 };
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 };