@ampless/mcp-server 0.2.0-alpha.8 → 1.0.0-alpha.10

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/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-IW52OUIR.js";
8
8
  import {
9
9
  tools
10
- } from "./chunk-EGQ7Q3Y3.js";
10
+ } from "./chunk-DAR6AHSX.js";
11
11
  import {
12
12
  AwsCrc32,
13
13
  __awaiter,
@@ -10895,10 +10895,6 @@ function parseArgs(argv) {
10895
10895
  out.outputs = argv[++i2];
10896
10896
  } else if (arg.startsWith("--outputs=")) {
10897
10897
  out.outputs = arg.slice("--outputs=".length);
10898
- } else if (arg === "--site-id") {
10899
- out.defaultSiteId = argv[++i2];
10900
- } else if (arg.startsWith("--site-id=")) {
10901
- out.defaultSiteId = arg.slice("--site-id=".length);
10902
10898
  }
10903
10899
  }
10904
10900
  return out;
@@ -10938,8 +10934,7 @@ async function loadConfig2(argv = process.argv.slice(2)) {
10938
10934
  return {
10939
10935
  outputs,
10940
10936
  email: requireEnv("AMPLESS_MCP_EMAIL"),
10941
- password: requireEnv("AMPLESS_MCP_PASSWORD"),
10942
- defaultSiteId: args.defaultSiteId ?? process.env.AMPLESS_MCP_SITE_ID ?? "default"
10937
+ password: requireEnv("AMPLESS_MCP_PASSWORD")
10943
10938
  };
10944
10939
  }
10945
10940
 
@@ -32067,6 +32062,32 @@ function isValidBase64EncodedSSECustomerKey(str, options) {
32067
32062
  }
32068
32063
  }
32069
32064
 
32065
+ // ../../node_modules/.pnpm/@aws-sdk+client-s3@3.1048.0/node_modules/@aws-sdk/client-s3/dist-es/commands/DeleteObjectCommand.js
32066
+ var DeleteObjectCommand = class extends Command.classBuilder().ep({
32067
+ ...commonParams,
32068
+ Bucket: { type: "contextParams", name: "Bucket" },
32069
+ Key: { type: "contextParams", name: "Key" }
32070
+ }).m(function(Command2, cs, config2, o2) {
32071
+ return [
32072
+ getEndpointPlugin(config2, Command2.getEndpointParameterInstructions()),
32073
+ getThrow200ExceptionsPlugin(config2)
32074
+ ];
32075
+ }).s("AmazonS3", "DeleteObject", {}).n("S3Client", "DeleteObjectCommand").sc(DeleteObject$).build() {
32076
+ };
32077
+
32078
+ // ../../node_modules/.pnpm/@aws-sdk+client-s3@3.1048.0/node_modules/@aws-sdk/client-s3/dist-es/commands/ListObjectsV2Command.js
32079
+ var ListObjectsV2Command = class extends Command.classBuilder().ep({
32080
+ ...commonParams,
32081
+ Bucket: { type: "contextParams", name: "Bucket" },
32082
+ Prefix: { type: "contextParams", name: "Prefix" }
32083
+ }).m(function(Command2, cs, config2, o2) {
32084
+ return [
32085
+ getEndpointPlugin(config2, Command2.getEndpointParameterInstructions()),
32086
+ getThrow200ExceptionsPlugin(config2)
32087
+ ];
32088
+ }).s("AmazonS3", "ListObjectsV2", {}).n("S3Client", "ListObjectsV2Command").sc(ListObjectsV2$).build() {
32089
+ };
32090
+
32070
32091
  // ../../node_modules/.pnpm/@aws-sdk+client-s3@3.1048.0/node_modules/@aws-sdk/client-s3/dist-es/commands/PutObjectCommand.js
32071
32092
  var PutObjectCommand = class extends Command.classBuilder().ep({
32072
32093
  ...commonParams,
@@ -32113,6 +32134,34 @@ var StorageClient = class {
32113
32134
  );
32114
32135
  return formatPublicAssetUrl(this.bucket, this.region, key);
32115
32136
  }
32137
+ async deleteObject(key) {
32138
+ await this.client.send(
32139
+ new DeleteObjectCommand({ Bucket: this.bucket, Key: key })
32140
+ );
32141
+ }
32142
+ async listObjects(prefix) {
32143
+ const out = [];
32144
+ let token;
32145
+ do {
32146
+ const res = await this.client.send(
32147
+ new ListObjectsV2Command({
32148
+ Bucket: this.bucket,
32149
+ Prefix: prefix,
32150
+ ContinuationToken: token
32151
+ })
32152
+ );
32153
+ for (const obj of res.Contents ?? []) {
32154
+ if (!obj.Key) continue;
32155
+ out.push({
32156
+ key: obj.Key,
32157
+ size: obj.Size ?? 0,
32158
+ lastModified: obj.LastModified?.toISOString()
32159
+ });
32160
+ }
32161
+ token = res.IsTruncated ? res.NextContinuationToken : void 0;
32162
+ } while (token);
32163
+ return out;
32164
+ }
32116
32165
  };
32117
32166
 
32118
32167
  // src/server.ts
@@ -32127,8 +32176,7 @@ async function startServer(config2) {
32127
32176
  };
32128
32177
  const ctx = {
32129
32178
  graphql,
32130
- storage,
32131
- defaultSiteId: config2.defaultSiteId
32179
+ storage
32132
32180
  };
32133
32181
  const server = new Server(
32134
32182
  { name: "@ampless/mcp-server", version: "0.0.1" },
@@ -1,3 +1,5 @@
1
+ import { BundleExtractResult } from 'ampless';
2
+
1
3
  /**
2
4
  * Abstract contracts each tool handler depends on. Concrete
3
5
  * implementations live elsewhere:
@@ -15,6 +17,14 @@
15
17
  interface GraphqlClient {
16
18
  query<T>(operation: string, variables?: Record<string, unknown>): Promise<T>;
17
19
  }
20
+ interface StorageObject {
21
+ /** Full S3 key including any prefix. */
22
+ key: string;
23
+ /** Object size in bytes (0 when the backend can't supply it). */
24
+ size: number;
25
+ /** ISO 8601 timestamp of the last write, when the backend supplies it. */
26
+ lastModified?: string;
27
+ }
18
28
  interface StorageClient {
19
29
  /**
20
30
  * Upload `body` to the bucket at `key` with `contentType`. Returns
@@ -22,13 +32,69 @@ interface StorageClient {
22
32
  * https://{bucket}.s3.{region}.amazonaws.com/{key}).
23
33
  */
24
34
  putObject(key: string, body: Uint8Array, contentType: string): Promise<string>;
35
+ /**
36
+ * Remove the object at `key`. Implementations should treat a missing
37
+ * key as success (S3 DeleteObject is idempotent by default).
38
+ */
39
+ deleteObject(key: string): Promise<void>;
40
+ /**
41
+ * List every object under `prefix`. Implementations are expected to
42
+ * paginate internally so the caller gets the full set in a single
43
+ * resolved promise — the static-bundle tools never expect more than
44
+ * a few hundred entries per bundle in practice.
45
+ */
46
+ listObjects(prefix: string): Promise<StorageObject[]>;
25
47
  }
26
48
  interface ToolContext {
27
49
  graphql: GraphqlClient;
28
50
  storage: () => StorageClient;
29
- defaultSiteId: string;
30
51
  }
31
52
 
53
+ /**
54
+ * Server-side zip extractor used by the static-bundle MCP tools. Both
55
+ * the stdio CLI and the Lambda HTTP transport run this — `fflate` is
56
+ * a workspace dependency of `@ampless/mcp-server`, so the import
57
+ * resolves identically in both. The browser-side admin uploader has
58
+ * its own `extractZip(File)` based on JSZip (works on a `File`, not a
59
+ * `Buffer`).
60
+ *
61
+ * Behaviour parity with the admin extractor:
62
+ * - Skip directory entries (fflate gives byte arrays only, so this
63
+ * is naturally satisfied unless the zip has empty-byte directory
64
+ * placeholders — those still get filtered out by validateBundlePath
65
+ * returning "directory entry" for any path ending with `/`).
66
+ * - Silently drop OS-specific junk (`__MACOSX/*`, `.DS_Store`,
67
+ * `Thumbs.db`) so callers don't see them as bundle entries.
68
+ * - Surface structural issues (absolute paths, parent traversal, null
69
+ * bytes) so the tool can reject the upload.
70
+ * - Strip a common single top-level directory (macOS Finder zips
71
+ * wrap their contents in a folder).
72
+ */
73
+
74
+ interface ExtractZipOptions {
75
+ /**
76
+ * Hard ceiling on uncompressed bundle bytes. Defaults to 50 MB,
77
+ * matching the browser uploader's MAX_BUNDLE_BYTES. Callers running
78
+ * inside a tight Lambda envelope (Function URL payload cap ~6 MB
79
+ * post-base64) can tighten this; setting it lower than the bundle
80
+ * causes `extractZipFromBuffer` to throw before fully populating
81
+ * `files`.
82
+ */
83
+ maxBytes?: number;
84
+ }
85
+ /**
86
+ * Unzip `buffer` in memory and return the same shape the browser
87
+ * `extractZip(File)` helper returns. Throws if the unzip itself fails
88
+ * (corrupt archive) or if the uncompressed size exceeds `maxBytes`.
89
+ */
90
+ declare function extractZipFromBuffer(buffer: Uint8Array, opts?: ExtractZipOptions): BundleExtractResult;
91
+ /**
92
+ * Decode an extracted file's bytes as UTF-8 text. Used by the tool
93
+ * handler before running cross-file `validateBundle` so we don't
94
+ * instantiate a TextDecoder per entry. fflate provides a fast helper.
95
+ */
96
+ declare function decodeUtf8(data: Uint8Array): string;
97
+
32
98
  interface ToolDefinition {
33
99
  name: string;
34
100
  description: string;
@@ -49,4 +115,4 @@ declare function dispatchToolCall(name: string, args: Record<string, unknown>, c
49
115
  */
50
116
  declare function getTools(): readonly ToolDefinition[];
51
117
 
52
- export { type GraphqlClient, type StorageClient, type ToolContext, type ToolDefinition, dispatchToolCall, getTools, tools };
118
+ export { type ExtractZipOptions, type GraphqlClient, type StorageClient, type StorageObject, type ToolContext, type ToolDefinition, decodeUtf8, dispatchToolCall, extractZipFromBuffer, getTools, tools };
@@ -1,12 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ decodeUtf8,
3
4
  dispatchToolCall,
5
+ extractZipFromBuffer,
4
6
  getTools,
5
7
  tools
6
- } from "../chunk-EGQ7Q3Y3.js";
8
+ } from "../chunk-DAR6AHSX.js";
7
9
  import "../chunk-LMMQX4CK.js";
8
10
  export {
11
+ decodeUtf8,
9
12
  dispatchToolCall,
13
+ extractZipFromBuffer,
10
14
  getTools,
11
15
  tools
12
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampless/mcp-server",
3
- "version": "0.2.0-alpha.8",
3
+ "version": "1.0.0-alpha.10",
4
4
  "description": "MCP server for ampless — lets AI agents (Claude Desktop, Cursor, Claude Code) read and write posts and media via AppSync",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -35,7 +35,8 @@
35
35
  "@modelcontextprotocol/sdk": "^1.0.0",
36
36
  "@aws-sdk/client-s3": "^3.1048.0",
37
37
  "amazon-cognito-identity-js": "^6.3.12",
38
- "ampless": "0.2.0-alpha.7"
38
+ "fflate": "^0.8.2",
39
+ "ampless": "1.0.0-alpha.9"
39
40
  },
40
41
  "keywords": [
41
42
  "ampless",