@ampless/mcp-server 0.2.0-alpha.7 → 0.2.0-alpha.9
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/chunk-4PTNHZO4.js +1004 -0
- package/dist/index.js +55 -1
- package/dist/tools/index.d.ts +68 -1
- package/dist/tools/index.js +5 -1
- package/package.json +3 -2
- package/dist/chunk-6LH275IC.js +0 -541
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-
|
|
10
|
+
} from "./chunk-4PTNHZO4.js";
|
|
11
11
|
import {
|
|
12
12
|
AwsCrc32,
|
|
13
13
|
__awaiter,
|
|
@@ -32067,6 +32067,32 @@ function isValidBase64EncodedSSECustomerKey(str, options) {
|
|
|
32067
32067
|
}
|
|
32068
32068
|
}
|
|
32069
32069
|
|
|
32070
|
+
// ../../node_modules/.pnpm/@aws-sdk+client-s3@3.1048.0/node_modules/@aws-sdk/client-s3/dist-es/commands/DeleteObjectCommand.js
|
|
32071
|
+
var DeleteObjectCommand = class extends Command.classBuilder().ep({
|
|
32072
|
+
...commonParams,
|
|
32073
|
+
Bucket: { type: "contextParams", name: "Bucket" },
|
|
32074
|
+
Key: { type: "contextParams", name: "Key" }
|
|
32075
|
+
}).m(function(Command2, cs, config2, o2) {
|
|
32076
|
+
return [
|
|
32077
|
+
getEndpointPlugin(config2, Command2.getEndpointParameterInstructions()),
|
|
32078
|
+
getThrow200ExceptionsPlugin(config2)
|
|
32079
|
+
];
|
|
32080
|
+
}).s("AmazonS3", "DeleteObject", {}).n("S3Client", "DeleteObjectCommand").sc(DeleteObject$).build() {
|
|
32081
|
+
};
|
|
32082
|
+
|
|
32083
|
+
// ../../node_modules/.pnpm/@aws-sdk+client-s3@3.1048.0/node_modules/@aws-sdk/client-s3/dist-es/commands/ListObjectsV2Command.js
|
|
32084
|
+
var ListObjectsV2Command = class extends Command.classBuilder().ep({
|
|
32085
|
+
...commonParams,
|
|
32086
|
+
Bucket: { type: "contextParams", name: "Bucket" },
|
|
32087
|
+
Prefix: { type: "contextParams", name: "Prefix" }
|
|
32088
|
+
}).m(function(Command2, cs, config2, o2) {
|
|
32089
|
+
return [
|
|
32090
|
+
getEndpointPlugin(config2, Command2.getEndpointParameterInstructions()),
|
|
32091
|
+
getThrow200ExceptionsPlugin(config2)
|
|
32092
|
+
];
|
|
32093
|
+
}).s("AmazonS3", "ListObjectsV2", {}).n("S3Client", "ListObjectsV2Command").sc(ListObjectsV2$).build() {
|
|
32094
|
+
};
|
|
32095
|
+
|
|
32070
32096
|
// ../../node_modules/.pnpm/@aws-sdk+client-s3@3.1048.0/node_modules/@aws-sdk/client-s3/dist-es/commands/PutObjectCommand.js
|
|
32071
32097
|
var PutObjectCommand = class extends Command.classBuilder().ep({
|
|
32072
32098
|
...commonParams,
|
|
@@ -32113,6 +32139,34 @@ var StorageClient = class {
|
|
|
32113
32139
|
);
|
|
32114
32140
|
return formatPublicAssetUrl(this.bucket, this.region, key);
|
|
32115
32141
|
}
|
|
32142
|
+
async deleteObject(key) {
|
|
32143
|
+
await this.client.send(
|
|
32144
|
+
new DeleteObjectCommand({ Bucket: this.bucket, Key: key })
|
|
32145
|
+
);
|
|
32146
|
+
}
|
|
32147
|
+
async listObjects(prefix) {
|
|
32148
|
+
const out = [];
|
|
32149
|
+
let token;
|
|
32150
|
+
do {
|
|
32151
|
+
const res = await this.client.send(
|
|
32152
|
+
new ListObjectsV2Command({
|
|
32153
|
+
Bucket: this.bucket,
|
|
32154
|
+
Prefix: prefix,
|
|
32155
|
+
ContinuationToken: token
|
|
32156
|
+
})
|
|
32157
|
+
);
|
|
32158
|
+
for (const obj of res.Contents ?? []) {
|
|
32159
|
+
if (!obj.Key) continue;
|
|
32160
|
+
out.push({
|
|
32161
|
+
key: obj.Key,
|
|
32162
|
+
size: obj.Size ?? 0,
|
|
32163
|
+
lastModified: obj.LastModified?.toISOString()
|
|
32164
|
+
});
|
|
32165
|
+
}
|
|
32166
|
+
token = res.IsTruncated ? res.NextContinuationToken : void 0;
|
|
32167
|
+
} while (token);
|
|
32168
|
+
return out;
|
|
32169
|
+
}
|
|
32116
32170
|
};
|
|
32117
32171
|
|
|
32118
32172
|
// src/server.ts
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -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,6 +32,18 @@ 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;
|
|
@@ -29,6 +51,51 @@ interface ToolContext {
|
|
|
29
51
|
defaultSiteId: string;
|
|
30
52
|
}
|
|
31
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Server-side zip extractor used by the static-bundle MCP tools. Both
|
|
56
|
+
* the stdio CLI and the Lambda HTTP transport run this — `fflate` is
|
|
57
|
+
* a workspace dependency of `@ampless/mcp-server`, so the import
|
|
58
|
+
* resolves identically in both. The browser-side admin uploader has
|
|
59
|
+
* its own `extractZip(File)` based on JSZip (works on a `File`, not a
|
|
60
|
+
* `Buffer`).
|
|
61
|
+
*
|
|
62
|
+
* Behaviour parity with the admin extractor:
|
|
63
|
+
* - Skip directory entries (fflate gives byte arrays only, so this
|
|
64
|
+
* is naturally satisfied unless the zip has empty-byte directory
|
|
65
|
+
* placeholders — those still get filtered out by validateBundlePath
|
|
66
|
+
* returning "directory entry" for any path ending with `/`).
|
|
67
|
+
* - Silently drop OS-specific junk (`__MACOSX/*`, `.DS_Store`,
|
|
68
|
+
* `Thumbs.db`) so callers don't see them as bundle entries.
|
|
69
|
+
* - Surface structural issues (absolute paths, parent traversal, null
|
|
70
|
+
* bytes) so the tool can reject the upload.
|
|
71
|
+
* - Strip a common single top-level directory (macOS Finder zips
|
|
72
|
+
* wrap their contents in a folder).
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
interface ExtractZipOptions {
|
|
76
|
+
/**
|
|
77
|
+
* Hard ceiling on uncompressed bundle bytes. Defaults to 50 MB,
|
|
78
|
+
* matching the browser uploader's MAX_BUNDLE_BYTES. Callers running
|
|
79
|
+
* inside a tight Lambda envelope (Function URL payload cap ~6 MB
|
|
80
|
+
* post-base64) can tighten this; setting it lower than the bundle
|
|
81
|
+
* causes `extractZipFromBuffer` to throw before fully populating
|
|
82
|
+
* `files`.
|
|
83
|
+
*/
|
|
84
|
+
maxBytes?: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Unzip `buffer` in memory and return the same shape the browser
|
|
88
|
+
* `extractZip(File)` helper returns. Throws if the unzip itself fails
|
|
89
|
+
* (corrupt archive) or if the uncompressed size exceeds `maxBytes`.
|
|
90
|
+
*/
|
|
91
|
+
declare function extractZipFromBuffer(buffer: Uint8Array, opts?: ExtractZipOptions): BundleExtractResult;
|
|
92
|
+
/**
|
|
93
|
+
* Decode an extracted file's bytes as UTF-8 text. Used by the tool
|
|
94
|
+
* handler before running cross-file `validateBundle` so we don't
|
|
95
|
+
* instantiate a TextDecoder per entry. fflate provides a fast helper.
|
|
96
|
+
*/
|
|
97
|
+
declare function decodeUtf8(data: Uint8Array): string;
|
|
98
|
+
|
|
32
99
|
interface ToolDefinition {
|
|
33
100
|
name: string;
|
|
34
101
|
description: string;
|
|
@@ -49,4 +116,4 @@ declare function dispatchToolCall(name: string, args: Record<string, unknown>, c
|
|
|
49
116
|
*/
|
|
50
117
|
declare function getTools(): readonly ToolDefinition[];
|
|
51
118
|
|
|
52
|
-
export { type GraphqlClient, type StorageClient, type ToolContext, type ToolDefinition, dispatchToolCall, getTools, tools };
|
|
119
|
+
export { type ExtractZipOptions, type GraphqlClient, type StorageClient, type StorageObject, type ToolContext, type ToolDefinition, decodeUtf8, dispatchToolCall, extractZipFromBuffer, getTools, tools };
|
package/dist/tools/index.js
CHANGED
|
@@ -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-
|
|
8
|
+
} from "../chunk-4PTNHZO4.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.
|
|
3
|
+
"version": "0.2.0-alpha.9",
|
|
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
|
-
"
|
|
38
|
+
"fflate": "^0.8.2",
|
|
39
|
+
"ampless": "0.2.0-alpha.8"
|
|
39
40
|
},
|
|
40
41
|
"keywords": [
|
|
41
42
|
"ampless",
|