@atengk/mcp-server-s3 0.0.0-stage → 1.0.1

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.
@@ -0,0 +1,1404 @@
1
+ import { S3Client } from '@aws-sdk/client-s3';
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { z } from 'zod';
4
+ import http from 'node:http';
5
+
6
+ /**
7
+ * 应用配置与环境契约模型定义
8
+ *
9
+ * @author Ateng
10
+ * @since 2026-10-04
11
+ */
12
+
13
+ /**
14
+ * MCP 通信传输模式枚举
15
+ */
16
+ declare const TransportModeSchema: z.ZodEnum<["stdio", "sse"]>;
17
+ type TransportMode = z.infer<typeof TransportModeSchema>;
18
+ /**
19
+ * S3 访问密钥凭证契约
20
+ */
21
+ declare const S3CredentialsConfigSchema: z.ZodObject<{
22
+ accessKeyId: z.ZodString;
23
+ secretAccessKey: z.ZodString;
24
+ sessionToken: z.ZodOptional<z.ZodString>;
25
+ }, "strip", z.ZodTypeAny, {
26
+ accessKeyId: string;
27
+ secretAccessKey: string;
28
+ sessionToken?: string | undefined;
29
+ }, {
30
+ accessKeyId: string;
31
+ secretAccessKey: string;
32
+ sessionToken?: string | undefined;
33
+ }>;
34
+ type S3CredentialsConfig = z.infer<typeof S3CredentialsConfigSchema>;
35
+ /**
36
+ * S3 客户端底层连接配置契约
37
+ */
38
+ declare const S3ClientConfigSchema: z.ZodObject<{
39
+ endpoint: z.ZodOptional<z.ZodString>;
40
+ region: z.ZodString;
41
+ credentials: z.ZodOptional<z.ZodObject<{
42
+ accessKeyId: z.ZodString;
43
+ secretAccessKey: z.ZodString;
44
+ sessionToken: z.ZodOptional<z.ZodString>;
45
+ }, "strip", z.ZodTypeAny, {
46
+ accessKeyId: string;
47
+ secretAccessKey: string;
48
+ sessionToken?: string | undefined;
49
+ }, {
50
+ accessKeyId: string;
51
+ secretAccessKey: string;
52
+ sessionToken?: string | undefined;
53
+ }>>;
54
+ forcePathStyle: z.ZodBoolean;
55
+ }, "strip", z.ZodTypeAny, {
56
+ region: string;
57
+ forcePathStyle: boolean;
58
+ endpoint?: string | undefined;
59
+ credentials?: {
60
+ accessKeyId: string;
61
+ secretAccessKey: string;
62
+ sessionToken?: string | undefined;
63
+ } | undefined;
64
+ }, {
65
+ region: string;
66
+ forcePathStyle: boolean;
67
+ endpoint?: string | undefined;
68
+ credentials?: {
69
+ accessKeyId: string;
70
+ secretAccessKey: string;
71
+ sessionToken?: string | undefined;
72
+ } | undefined;
73
+ }>;
74
+ type S3ClientConfig = z.infer<typeof S3ClientConfigSchema>;
75
+ /**
76
+ * 12-Factor App 全局集中配置运行时校验 Schema
77
+ */
78
+ declare const AppConfigSchema: z.ZodObject<{
79
+ transport: z.ZodEnum<["stdio", "sse"]>;
80
+ serverHost: z.ZodString;
81
+ serverPort: z.ZodNumber;
82
+ endpoint: z.ZodOptional<z.ZodString>;
83
+ region: z.ZodString;
84
+ accessKeyId: z.ZodOptional<z.ZodString>;
85
+ secretAccessKey: z.ZodOptional<z.ZodString>;
86
+ sessionToken: z.ZodOptional<z.ZodString>;
87
+ forcePathStyle: z.ZodBoolean;
88
+ defaultBucket: z.ZodOptional<z.ZodString>;
89
+ readOnly: z.ZodBoolean;
90
+ allowedLocalDir: z.ZodString;
91
+ maxReadBytes: z.ZodNumber;
92
+ presignedExpires: z.ZodNumber;
93
+ apiKey: z.ZodOptional<z.ZodString>;
94
+ }, "strip", z.ZodTypeAny, {
95
+ transport: "stdio" | "sse";
96
+ serverHost: string;
97
+ serverPort: number;
98
+ region: string;
99
+ forcePathStyle: boolean;
100
+ readOnly: boolean;
101
+ allowedLocalDir: string;
102
+ maxReadBytes: number;
103
+ presignedExpires: number;
104
+ endpoint?: string | undefined;
105
+ accessKeyId?: string | undefined;
106
+ secretAccessKey?: string | undefined;
107
+ sessionToken?: string | undefined;
108
+ defaultBucket?: string | undefined;
109
+ apiKey?: string | undefined;
110
+ }, {
111
+ transport: "stdio" | "sse";
112
+ serverHost: string;
113
+ serverPort: number;
114
+ region: string;
115
+ forcePathStyle: boolean;
116
+ readOnly: boolean;
117
+ allowedLocalDir: string;
118
+ maxReadBytes: number;
119
+ presignedExpires: number;
120
+ endpoint?: string | undefined;
121
+ accessKeyId?: string | undefined;
122
+ secretAccessKey?: string | undefined;
123
+ sessionToken?: string | undefined;
124
+ defaultBucket?: string | undefined;
125
+ apiKey?: string | undefined;
126
+ }>;
127
+ type AppConfig = z.infer<typeof AppConfigSchema>;
128
+
129
+ /**
130
+ * S3 核心领域数据模型契约 (严格遵循 CONTEXT.md 统一领域语言)
131
+ *
132
+ * @author Ateng
133
+ * @since 2026-10-04
134
+ */
135
+
136
+ /**
137
+ * 统一错误返回契约 Schema
138
+ */
139
+ declare const ErrorResultSchema: z.ZodObject<{
140
+ status: z.ZodLiteral<"error">;
141
+ code: z.ZodString;
142
+ message: z.ZodString;
143
+ details: z.ZodOptional<z.ZodUnknown>;
144
+ }, "strip", z.ZodTypeAny, {
145
+ code: string;
146
+ message: string;
147
+ status: "error";
148
+ details?: unknown;
149
+ }, {
150
+ code: string;
151
+ message: string;
152
+ status: "error";
153
+ details?: unknown;
154
+ }>;
155
+ type ErrorResult = z.infer<typeof ErrorResultSchema>;
156
+ /**
157
+ * 存储桶 (Bucket) 基础信息契约
158
+ */
159
+ interface BucketItem {
160
+ name: string;
161
+ creationDate?: Date;
162
+ }
163
+ /**
164
+ * 对象 (Object) 摘要契约
165
+ */
166
+ interface S3ObjectItem {
167
+ key: string;
168
+ size?: number;
169
+ lastModified?: Date;
170
+ etag?: string;
171
+ storageClass?: string;
172
+ }
173
+ /**
174
+ * 虚拟目录公共前缀契约
175
+ */
176
+ interface CommonPrefixItem {
177
+ prefix: string;
178
+ }
179
+ /**
180
+ * 对象列表分页查询结果契约
181
+ */
182
+ interface ListObjectsResult {
183
+ bucket: string;
184
+ prefix?: string;
185
+ delimiter?: string;
186
+ objects: S3ObjectItem[];
187
+ commonPrefixes: string[];
188
+ nextContinuationToken?: string;
189
+ isTruncated: boolean;
190
+ }
191
+ /**
192
+ * 对象元数据与属性契约
193
+ */
194
+ interface ObjectMetadata {
195
+ bucket: string;
196
+ key: string;
197
+ size?: number;
198
+ contentType?: string;
199
+ lastModified?: Date;
200
+ etag?: string;
201
+ metadata?: Record<string, string>;
202
+ }
203
+ /**
204
+ * 文本直读响应契约 (含截断警示)
205
+ */
206
+ interface ReadObjectTextResult {
207
+ bucket: string;
208
+ key: string;
209
+ content: string;
210
+ truncated: boolean;
211
+ totalBytes?: number;
212
+ readBytes: number;
213
+ warning?: string;
214
+ }
215
+ /**
216
+ * HTTP Range 字节范围读取响应契约
217
+ */
218
+ interface RangeReadResult {
219
+ bucket: string;
220
+ key: string;
221
+ startByte: number;
222
+ endByte: number;
223
+ contentLength: number;
224
+ dataBase64?: string;
225
+ text?: string;
226
+ }
227
+ /**
228
+ * 预签名 URL 直链结果契约
229
+ */
230
+ interface PresignedUrlResult {
231
+ bucket: string;
232
+ key: string;
233
+ url: string;
234
+ expiresIn: number;
235
+ method: "GET" | "PUT";
236
+ }
237
+ /**
238
+ * 连通性自省探针 (s3_ping) 诊断结果契约
239
+ */
240
+ declare const ConnectivityProbeResultSchema: z.ZodObject<{
241
+ status: z.ZodEnum<["ok", "error"]>;
242
+ endpoint: z.ZodOptional<z.ZodString>;
243
+ region: z.ZodString;
244
+ accessKeyIdMasked: z.ZodOptional<z.ZodString>;
245
+ rttMs: z.ZodNumber;
246
+ message: z.ZodString;
247
+ }, "strip", z.ZodTypeAny, {
248
+ region: string;
249
+ message: string;
250
+ status: "error" | "ok";
251
+ rttMs: number;
252
+ endpoint?: string | undefined;
253
+ accessKeyIdMasked?: string | undefined;
254
+ }, {
255
+ region: string;
256
+ message: string;
257
+ status: "error" | "ok";
258
+ rttMs: number;
259
+ endpoint?: string | undefined;
260
+ accessKeyIdMasked?: string | undefined;
261
+ }>;
262
+ type ConnectivityProbeResult = z.infer<typeof ConnectivityProbeResultSchema>;
263
+ /**
264
+ * 对象键值标签项
265
+ */
266
+ interface TagItem {
267
+ key: string;
268
+ value: string;
269
+ }
270
+ /**
271
+ * 对象标签字典映射
272
+ */
273
+ type ObjectTags = Record<string, string>;
274
+
275
+ /**
276
+ * MCP 工具输入输出契约与 Zod 运行时校验 Schema
277
+ *
278
+ * @author Ateng
279
+ * @since 2026-10-04
280
+ */
281
+
282
+ /**
283
+ * 0. 连通性自省探针工具入参 Schema
284
+ */
285
+ declare const S3PingSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
286
+ type S3PingInput = z.infer<typeof S3PingSchema>;
287
+ /**
288
+ * 1. 存储桶生命周期工具入参 Schemas
289
+ */
290
+ declare const ListBucketsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
291
+ type ListBucketsInput = z.infer<typeof ListBucketsSchema>;
292
+ declare const CreateBucketSchema: z.ZodObject<{
293
+ bucket: z.ZodString;
294
+ region: z.ZodOptional<z.ZodString>;
295
+ }, "strip", z.ZodTypeAny, {
296
+ bucket: string;
297
+ region?: string | undefined;
298
+ }, {
299
+ bucket: string;
300
+ region?: string | undefined;
301
+ }>;
302
+ type CreateBucketInput = z.infer<typeof CreateBucketSchema>;
303
+ declare const DeleteBucketSchema: z.ZodObject<{
304
+ bucket: z.ZodString;
305
+ force: z.ZodOptional<z.ZodBoolean>;
306
+ }, "strip", z.ZodTypeAny, {
307
+ bucket: string;
308
+ force?: boolean | undefined;
309
+ }, {
310
+ bucket: string;
311
+ force?: boolean | undefined;
312
+ }>;
313
+ type DeleteBucketInput = z.infer<typeof DeleteBucketSchema>;
314
+ declare const GetBucketLocationSchema: z.ZodObject<{
315
+ bucket: z.ZodString;
316
+ }, "strip", z.ZodTypeAny, {
317
+ bucket: string;
318
+ }, {
319
+ bucket: string;
320
+ }>;
321
+ type GetBucketLocationInput = z.infer<typeof GetBucketLocationSchema>;
322
+ /**
323
+ * 2. 检索探索定位工具入参 Schemas
324
+ */
325
+ declare const ListObjectsSchema: z.ZodObject<{
326
+ bucket: z.ZodOptional<z.ZodString>;
327
+ prefix: z.ZodOptional<z.ZodString>;
328
+ delimiter: z.ZodOptional<z.ZodString>;
329
+ max_keys: z.ZodOptional<z.ZodNumber>;
330
+ continuation_token: z.ZodOptional<z.ZodString>;
331
+ }, "strip", z.ZodTypeAny, {
332
+ bucket?: string | undefined;
333
+ prefix?: string | undefined;
334
+ delimiter?: string | undefined;
335
+ max_keys?: number | undefined;
336
+ continuation_token?: string | undefined;
337
+ }, {
338
+ bucket?: string | undefined;
339
+ prefix?: string | undefined;
340
+ delimiter?: string | undefined;
341
+ max_keys?: number | undefined;
342
+ continuation_token?: string | undefined;
343
+ }>;
344
+ type ListObjectsInput = z.infer<typeof ListObjectsSchema>;
345
+ declare const SearchObjectsSchema: z.ZodObject<{
346
+ bucket: z.ZodOptional<z.ZodString>;
347
+ query: z.ZodString;
348
+ prefix: z.ZodOptional<z.ZodString>;
349
+ max_results: z.ZodOptional<z.ZodNumber>;
350
+ }, "strip", z.ZodTypeAny, {
351
+ query: string;
352
+ bucket?: string | undefined;
353
+ prefix?: string | undefined;
354
+ max_results?: number | undefined;
355
+ }, {
356
+ query: string;
357
+ bucket?: string | undefined;
358
+ prefix?: string | undefined;
359
+ max_results?: number | undefined;
360
+ }>;
361
+ type SearchObjectsInput = z.infer<typeof SearchObjectsSchema>;
362
+ declare const StatObjectSchema: z.ZodObject<{
363
+ bucket: z.ZodOptional<z.ZodString>;
364
+ key: z.ZodString;
365
+ }, "strip", z.ZodTypeAny, {
366
+ key: string;
367
+ bucket?: string | undefined;
368
+ }, {
369
+ key: string;
370
+ bucket?: string | undefined;
371
+ }>;
372
+ type StatObjectInput = z.infer<typeof StatObjectSchema>;
373
+ /**
374
+ * 3. 内容检视分块工具入参 Schemas
375
+ */
376
+ declare const ReadObjectTextSchema: z.ZodObject<{
377
+ bucket: z.ZodOptional<z.ZodString>;
378
+ key: z.ZodString;
379
+ max_bytes: z.ZodOptional<z.ZodNumber>;
380
+ encoding: z.ZodOptional<z.ZodString>;
381
+ }, "strip", z.ZodTypeAny, {
382
+ key: string;
383
+ bucket?: string | undefined;
384
+ max_bytes?: number | undefined;
385
+ encoding?: string | undefined;
386
+ }, {
387
+ key: string;
388
+ bucket?: string | undefined;
389
+ max_bytes?: number | undefined;
390
+ encoding?: string | undefined;
391
+ }>;
392
+ type ReadObjectTextInput = z.infer<typeof ReadObjectTextSchema>;
393
+ declare const ReadObjectRangeSchema: z.ZodObject<{
394
+ bucket: z.ZodOptional<z.ZodString>;
395
+ key: z.ZodString;
396
+ start_byte: z.ZodNumber;
397
+ end_byte: z.ZodNumber;
398
+ }, "strip", z.ZodTypeAny, {
399
+ key: string;
400
+ start_byte: number;
401
+ end_byte: number;
402
+ bucket?: string | undefined;
403
+ }, {
404
+ key: string;
405
+ start_byte: number;
406
+ end_byte: number;
407
+ bucket?: string | undefined;
408
+ }>;
409
+ type ReadObjectRangeInput = z.infer<typeof ReadObjectRangeSchema>;
410
+ /**
411
+ * 4. 双向流式传输工具入参 Schemas
412
+ */
413
+ declare const PutObjectTextSchema: z.ZodObject<{
414
+ bucket: z.ZodOptional<z.ZodString>;
415
+ key: z.ZodString;
416
+ content: z.ZodString;
417
+ content_type: z.ZodOptional<z.ZodString>;
418
+ }, "strip", z.ZodTypeAny, {
419
+ content: string;
420
+ key: string;
421
+ bucket?: string | undefined;
422
+ content_type?: string | undefined;
423
+ }, {
424
+ content: string;
425
+ key: string;
426
+ bucket?: string | undefined;
427
+ content_type?: string | undefined;
428
+ }>;
429
+ type PutObjectTextInput = z.infer<typeof PutObjectTextSchema>;
430
+ declare const UploadFileSchema: z.ZodObject<{
431
+ bucket: z.ZodOptional<z.ZodString>;
432
+ key: z.ZodString;
433
+ local_path: z.ZodString;
434
+ content_type: z.ZodOptional<z.ZodString>;
435
+ }, "strip", z.ZodTypeAny, {
436
+ key: string;
437
+ local_path: string;
438
+ bucket?: string | undefined;
439
+ content_type?: string | undefined;
440
+ }, {
441
+ key: string;
442
+ local_path: string;
443
+ bucket?: string | undefined;
444
+ content_type?: string | undefined;
445
+ }>;
446
+ type UploadFileInput = z.infer<typeof UploadFileSchema>;
447
+ declare const DownloadFileSchema: z.ZodObject<{
448
+ bucket: z.ZodOptional<z.ZodString>;
449
+ key: z.ZodString;
450
+ local_path: z.ZodString;
451
+ }, "strip", z.ZodTypeAny, {
452
+ key: string;
453
+ local_path: string;
454
+ bucket?: string | undefined;
455
+ }, {
456
+ key: string;
457
+ local_path: string;
458
+ bucket?: string | undefined;
459
+ }>;
460
+ type DownloadFileInput = z.infer<typeof DownloadFileSchema>;
461
+ declare const GetPresignedUrlSchema: z.ZodObject<{
462
+ bucket: z.ZodOptional<z.ZodString>;
463
+ key: z.ZodString;
464
+ expires_in: z.ZodOptional<z.ZodNumber>;
465
+ method: z.ZodOptional<z.ZodEnum<["GET", "PUT"]>>;
466
+ }, "strip", z.ZodTypeAny, {
467
+ key: string;
468
+ method?: "GET" | "PUT" | undefined;
469
+ bucket?: string | undefined;
470
+ expires_in?: number | undefined;
471
+ }, {
472
+ key: string;
473
+ method?: "GET" | "PUT" | undefined;
474
+ bucket?: string | undefined;
475
+ expires_in?: number | undefined;
476
+ }>;
477
+ type GetPresignedUrlInput = z.infer<typeof GetPresignedUrlSchema>;
478
+ /**
479
+ * 5. 批处理与标签治理工具入参 Schemas
480
+ */
481
+ declare const CopyObjectSchema: z.ZodObject<{
482
+ source_bucket: z.ZodOptional<z.ZodString>;
483
+ source_key: z.ZodString;
484
+ target_bucket: z.ZodOptional<z.ZodString>;
485
+ target_key: z.ZodString;
486
+ }, "strip", z.ZodTypeAny, {
487
+ source_key: string;
488
+ target_key: string;
489
+ source_bucket?: string | undefined;
490
+ target_bucket?: string | undefined;
491
+ }, {
492
+ source_key: string;
493
+ target_key: string;
494
+ source_bucket?: string | undefined;
495
+ target_bucket?: string | undefined;
496
+ }>;
497
+ type CopyObjectInput = z.infer<typeof CopyObjectSchema>;
498
+ declare const MoveObjectSchema: z.ZodObject<{
499
+ source_bucket: z.ZodOptional<z.ZodString>;
500
+ source_key: z.ZodString;
501
+ target_bucket: z.ZodOptional<z.ZodString>;
502
+ target_key: z.ZodString;
503
+ }, "strip", z.ZodTypeAny, {
504
+ source_key: string;
505
+ target_key: string;
506
+ source_bucket?: string | undefined;
507
+ target_bucket?: string | undefined;
508
+ }, {
509
+ source_key: string;
510
+ target_key: string;
511
+ source_bucket?: string | undefined;
512
+ target_bucket?: string | undefined;
513
+ }>;
514
+ type MoveObjectInput = z.infer<typeof MoveObjectSchema>;
515
+ declare const DeleteObjectSchema: z.ZodObject<{
516
+ bucket: z.ZodOptional<z.ZodString>;
517
+ key: z.ZodString;
518
+ }, "strip", z.ZodTypeAny, {
519
+ key: string;
520
+ bucket?: string | undefined;
521
+ }, {
522
+ key: string;
523
+ bucket?: string | undefined;
524
+ }>;
525
+ type DeleteObjectInput = z.infer<typeof DeleteObjectSchema>;
526
+ declare const DeleteObjectsBatchSchema: z.ZodObject<{
527
+ bucket: z.ZodOptional<z.ZodString>;
528
+ keys: z.ZodArray<z.ZodString, "many">;
529
+ }, "strip", z.ZodTypeAny, {
530
+ keys: string[];
531
+ bucket?: string | undefined;
532
+ }, {
533
+ keys: string[];
534
+ bucket?: string | undefined;
535
+ }>;
536
+ type DeleteObjectsBatchInput = z.infer<typeof DeleteObjectsBatchSchema>;
537
+ declare const DeleteObjectsByPrefixSchema: z.ZodObject<{
538
+ bucket: z.ZodOptional<z.ZodString>;
539
+ prefix: z.ZodString;
540
+ confirm_recursive_delete: z.ZodBoolean;
541
+ }, "strip", z.ZodTypeAny, {
542
+ prefix: string;
543
+ confirm_recursive_delete: boolean;
544
+ bucket?: string | undefined;
545
+ }, {
546
+ prefix: string;
547
+ confirm_recursive_delete: boolean;
548
+ bucket?: string | undefined;
549
+ }>;
550
+ type DeleteObjectsByPrefixInput = z.infer<typeof DeleteObjectsByPrefixSchema>;
551
+ declare const GetObjectTagsSchema: z.ZodObject<{
552
+ bucket: z.ZodOptional<z.ZodString>;
553
+ key: z.ZodString;
554
+ }, "strip", z.ZodTypeAny, {
555
+ key: string;
556
+ bucket?: string | undefined;
557
+ }, {
558
+ key: string;
559
+ bucket?: string | undefined;
560
+ }>;
561
+ type GetObjectTagsInput = z.infer<typeof GetObjectTagsSchema>;
562
+ declare const SetObjectTagsSchema: z.ZodObject<{
563
+ bucket: z.ZodOptional<z.ZodString>;
564
+ key: z.ZodString;
565
+ tags: z.ZodRecord<z.ZodString, z.ZodString>;
566
+ }, "strip", z.ZodTypeAny, {
567
+ key: string;
568
+ tags: Record<string, string>;
569
+ bucket?: string | undefined;
570
+ }, {
571
+ key: string;
572
+ tags: Record<string, string>;
573
+ bucket?: string | undefined;
574
+ }>;
575
+ type SetObjectTagsInput = z.infer<typeof SetObjectTagsSchema>;
576
+
577
+ /**
578
+ * 安全防御与防灾体系契约模型
579
+ *
580
+ * @author Ateng
581
+ * @since 2026-10-04
582
+ */
583
+
584
+ /**
585
+ * 安全拦截检查结果契约
586
+ */
587
+ interface SecurityCheckResult {
588
+ /**
589
+ * 是否允许继续执行目标操作
590
+ */
591
+ isAllowed: boolean;
592
+ /**
593
+ * 拦截或放行的业务/安全原因说明
594
+ */
595
+ reason?: string;
596
+ }
597
+ /**
598
+ * 文本内容截断与二进制检视结果契约
599
+ */
600
+ interface ContentTruncationResult {
601
+ /**
602
+ * 最终呈现的文本内容 (超量时包含截断警示 notice)
603
+ */
604
+ content: string;
605
+ /**
606
+ * 是否触发了防爆截断或拦截
607
+ */
608
+ isTruncated: boolean;
609
+ /**
610
+ * 原始字节流的总字节数
611
+ */
612
+ totalBytes: number;
613
+ /**
614
+ * 本次实际读取并保留的字节数
615
+ */
616
+ readBytes: number;
617
+ /**
618
+ * 是否判定为二进制文件
619
+ */
620
+ isBinary: boolean;
621
+ /**
622
+ * 截断或二进制拦截诊断警告说明
623
+ */
624
+ warning?: string;
625
+ }
626
+ /**
627
+ * 安全违规错误类型枚举
628
+ */
629
+ declare const SecurityErrorCodeSchema: z.ZodEnum<["READONLY_VIOLATION", "SANDBOX_VIOLATION", "PREFIX_DELETION_VIOLATION", "BINARY_CONTENT_DETECTED"]>;
630
+ type SecurityErrorCode = z.infer<typeof SecurityErrorCodeSchema>;
631
+ /**
632
+ * 安全防御违规专用业务异常
633
+ */
634
+ declare class SecurityError extends Error {
635
+ readonly code: SecurityErrorCode;
636
+ constructor(code: SecurityErrorCode, message: string);
637
+ }
638
+ /**
639
+ * 业务操作受控异常 (Business Error)
640
+ */
641
+ declare class BusinessError extends Error {
642
+ readonly code: string;
643
+ constructor(code: string, message: string);
644
+ }
645
+
646
+ /**
647
+ * 环境变量解析器与集中配置管理中枢 (12-Factor App)
648
+ *
649
+ * @author Ateng
650
+ * @since 2026-10-04
651
+ */
652
+
653
+ /**
654
+ * 从环境变量映射中按优先级提取值
655
+ *
656
+ * 优先读取 MCP_S3_* 规范前缀,缺失时依次降级尝试备选键名
657
+ *
658
+ * @param env 环境变量键值对
659
+ * @param canonicalKey 官方标准主键名 (如 MCP_S3_REGION)
660
+ * @param fallbackKeys 备选向下兼容键名列表 (如 AWS_REGION)
661
+ * @return 命中的非空字符串,未命中时返回 undefined
662
+ */
663
+ declare function getEnvValue(env: NodeJS.ProcessEnv, canonicalKey: string, fallbackKeys?: string[]): string | undefined;
664
+ /**
665
+ * 宽容布尔值转换器
666
+ *
667
+ * 支持 1, true, yes, on, t (大小写不敏感) 为 true;
668
+ * 0, false, no, off, f, 空字符串 为 false;其余情况返回 defaultValue。
669
+ *
670
+ * @param value 环境变量原始值
671
+ * @param defaultValue 缺省默认值
672
+ * @return 解析后的布尔值
673
+ */
674
+ declare function parseBoolean(value: string | undefined, defaultValue: boolean): boolean;
675
+ /**
676
+ * 通用安全整数数值解析器 (支持边界校验)
677
+ *
678
+ * @param value 原始环境变量字符串
679
+ * @param defaultValue 默认数值
680
+ * @param fieldName 字段名称 (用于友好错误提示)
681
+ * @param min 允许的最小值 (包含,缺省为 0)
682
+ * @param max 允许的最大值 (包含,缺省为 Number.MAX_SAFE_INTEGER)
683
+ * @return 解析后的有效整数数值
684
+ * @throws 当输入非整数或超出 [min, max] 区间时抛出语义化异常
685
+ */
686
+ declare function parseNumber(value: string | undefined, defaultValue: number, fieldName: string, min?: number, max?: number): number;
687
+ /**
688
+ * 校验并解析有效网络端口号 (1-65535)
689
+ *
690
+ * @param value 原始环境变量字符串
691
+ * @param defaultPort 默认端口
692
+ * @param fieldName 字段名称
693
+ * @return 解析后的有效端口号
694
+ */
695
+ declare function parsePort(value: string | undefined, defaultPort: number, fieldName: string): number;
696
+ /**
697
+ * 校验并解析正整数数值 (>= 1)
698
+ *
699
+ * @param value 原始环境变量字符串
700
+ * @param defaultValue 默认数值
701
+ * @param fieldName 字段名称
702
+ * @return 解析后的正整数
703
+ */
704
+ declare function parsePositiveInt(value: string | undefined, defaultValue: number, fieldName: string): number;
705
+ /**
706
+ * 解析并生成全局类型化应用配置
707
+ *
708
+ * @param env 输入的环境变量字典,缺省默认使用当前 process.env
709
+ * @return 结构完整且经过强校验的 AppConfig 对象
710
+ */
711
+ declare function parseEnv(env?: NodeJS.ProcessEnv): AppConfig;
712
+ /**
713
+ * 敏感凭证数据安全脱敏 (强类型浅拷贝,保护明文密钥)
714
+ *
715
+ * @param config 原始应用配置对象
716
+ * @return 字段已脱敏的安全配置对象
717
+ */
718
+ declare function maskSensitiveConfig(config: AppConfig): AppConfig;
719
+ /**
720
+ * 对 AccessKeyId 进行掩码脱敏 (保留前后四位)
721
+ *
722
+ * @param accessKeyId 原始 AccessKey 字符串
723
+ * @return 脱敏后的字符串
724
+ */
725
+ declare function maskAccessKey(accessKeyId?: string): string | undefined;
726
+
727
+ /**
728
+ * S3 客户端单例工厂与连接管理器
729
+ *
730
+ * @author Ateng
731
+ * @since 2026-10-04
732
+ */
733
+
734
+ /**
735
+ * 根据应用配置装配 S3ClientConfig 选项 (包含重试与寻址策略)
736
+ *
737
+ * @param config 应用全局配置
738
+ * @return 组装后的底层客户端选项
739
+ */
740
+ declare function getS3ClientConfig(config: AppConfig): S3ClientConfig;
741
+ /**
742
+ * 根据应用配置创建全新的 S3Client 实例 (支持默认 3 次重试策略)
743
+ *
744
+ * @param config 应用全局配置
745
+ * @return 全新实例化的 S3Client 对象
746
+ */
747
+ declare function createS3Client(config: AppConfig): S3Client;
748
+ /**
749
+ * 获取或创建全局单例 S3Client 实例 (具备配置变动感知重建能力)
750
+ *
751
+ * @param config 可选应用配置,缺失时直接复用既有单例或加载当前环境变量解析
752
+ * @return 缓存或新创建的单例 S3Client 实例
753
+ */
754
+ declare function getS3Client(config?: AppConfig): S3Client;
755
+ /**
756
+ * 销毁并重置当前的单例客户端
757
+ */
758
+ declare function resetS3Client(): void;
759
+
760
+ /**
761
+ * 全局只读门禁守卫 (Read-Only Guard)
762
+ *
763
+ * 当启用只读门禁模式时,在 MCP 协议层完全隐藏并阻断写/删类高危工具
764
+ *
765
+ * @author Ateng
766
+ * @since 2026-10-04
767
+ */
768
+ /**
769
+ * 只读门禁守卫
770
+ */
771
+ declare class ReadOnlyGuard {
772
+ /**
773
+ * 允许在只读模式下调用的只读/探索类工具列表
774
+ */
775
+ static readonly READ_ONLY_TOOLS: Set<string>;
776
+ /**
777
+ * 写/改/删高危工具清单
778
+ */
779
+ static readonly MUTATING_TOOLS: Set<string>;
780
+ private isReadOnly;
781
+ constructor(isReadOnly?: boolean);
782
+ /**
783
+ * 判定目标工具是否属于写/改/删高危工具
784
+ *
785
+ * @param toolName 工具名称
786
+ * @return 是否为变更操作类工具
787
+ */
788
+ static isMutatingTool(toolName: string): boolean;
789
+ /**
790
+ * 判断目标工具在当前门禁状态下是否被允许调用
791
+ *
792
+ * @param toolName 工具名称
793
+ * @return 是否允许调用
794
+ */
795
+ isToolAllowed(toolName: string): boolean;
796
+ /**
797
+ * 断言目标工具在当前门禁状态下可调用;若属于写/删高危工具且处于只读模式则抛出异常
798
+ *
799
+ * @param toolName 工具名称
800
+ * @throws 当处于只读模式且尝试调用高危工具时抛出 SecurityError
801
+ */
802
+ assertToolAllowed(toolName: string): void;
803
+ /**
804
+ * 校验预签名 URL 方法;只读模式下严禁生成 PUT 上传直链
805
+ *
806
+ * @param method HTTP 请求方法
807
+ * @throws 当只读模式下请求 PUT 链接时抛出 SecurityError
808
+ */
809
+ assertPresignedUrlMethodAllowed(method?: "GET" | "PUT"): void;
810
+ /**
811
+ * 在 MCP 协议握手层物理过滤工具集合,在只读模式下隐藏所有写/删类工具
812
+ *
813
+ * @param tools 原始工具定义列表
814
+ * @return 过滤后的安全工具定义列表
815
+ */
816
+ filterTools<T extends {
817
+ name: string;
818
+ }>(tools: T[]): T[];
819
+ }
820
+
821
+ /**
822
+ * 工作区路径沙箱守卫 (Sandbox Guard)
823
+ *
824
+ * 严格限制本地文件读写在受管工作区目录内,强力阻断路径遍历逃逸 (../)、符号链接穿透与宿主机敏感文件泄露
825
+ *
826
+ * @author Ateng
827
+ * @since 2026-10-04
828
+ */
829
+ /**
830
+ * 本地沙箱隔离守卫
831
+ */
832
+ declare class SandboxGuard {
833
+ private allowedBaseDir;
834
+ constructor(allowedBaseDir?: string);
835
+ /**
836
+ * 获取当前生效的规范化沙箱根目录绝对路径
837
+ *
838
+ * @return 沙箱绝对路径
839
+ */
840
+ getBaseDir(): string;
841
+ /**
842
+ * 解析路径或其最接近的已存在父目录的真实物理路径 (Symlink 展开)
843
+ *
844
+ * @param targetPath 目标绝对路径
845
+ * @return 经过符号链接解析后的真实物理路径
846
+ */
847
+ private resolveRealPath;
848
+ /**
849
+ * 校验并规范化目标本地路径
850
+ *
851
+ * @param localPath 待校验的原始本地文件路径 (相对路径或绝对路径)
852
+ * @return 经过沙箱约束校验的安全绝对路径
853
+ * @throws 当路径为空、超出沙箱边界或通过 Symlink 逃逸时抛出 SecurityError
854
+ */
855
+ validatePath(localPath: string): string;
856
+ }
857
+
858
+ /**
859
+ * 前缀删除防灾熔断守卫 (Prefix Deletion Guard)
860
+ *
861
+ * 实施三重防灾熔断:非空非根前缀防护、显式二次确认校验与千级单批次安全上限
862
+ *
863
+ * @author Ateng
864
+ * @since 2026-10-04
865
+ */
866
+ /**
867
+ * 递归前缀清理防灾守卫
868
+ */
869
+ declare class PrefixDeletionGuard {
870
+ /**
871
+ * S3 标准单批次批量删除上限 (1000 个对象)
872
+ */
873
+ static readonly MAX_BATCH_DELETE_LIMIT = 1000;
874
+ /**
875
+ * 检验递归删除前缀并校验显式确认标记
876
+ *
877
+ * @param prefix 目标前缀字符串
878
+ * @param confirmRecursiveDelete 二次确认布尔标识
879
+ * @return 经过校验与规范化的安全前缀
880
+ * @throws 当缺少确认标记、前缀为空或为根斜杠时抛出 SecurityError
881
+ */
882
+ static validate(prefix: string, confirmRecursiveDelete: boolean): string;
883
+ /**
884
+ * 校验批量删除的对象键列表上限 (第三重防灾熔断)
885
+ *
886
+ * @param keys 待批量删除的对象键列表
887
+ * @return 校验通过的对象键列表
888
+ * @throws 当列表为空或元素数量超过 1000 时抛出 SecurityError
889
+ */
890
+ static validateBatchKeys(keys: string[]): string[];
891
+ }
892
+
893
+ /**
894
+ * 文本直读智能截断器与二进制拦截器 (Content Truncator)
895
+ *
896
+ * 限制 read_object_text 单次读取安全阈值 (默认 256KB),防止大日志撑爆上下文,智能拦截二进制文件并提供安全操作引导
897
+ *
898
+ * @author Ateng
899
+ * @since 2026-10-04
900
+ */
901
+
902
+ /**
903
+ * 默认文本直读最大安全阈值:256KB (262144 字节)
904
+ */
905
+ declare const DEFAULT_MAX_READ_BYTES = 262144;
906
+ /**
907
+ * 计算安全的 UTF-8 切割点,防止截断多字节字符引发乱码
908
+ *
909
+ * @param buf 待切片 Buffer
910
+ * @param limit 期望的截断字节数上限
911
+ * @return 确保 UTF-8 字符序列完整性的安全切割索引
912
+ */
913
+ declare function findSafeUtf8CutPoint(buf: Buffer, limit: number): number;
914
+ /**
915
+ * 截断器构造配置项
916
+ */
917
+ interface ContentTruncatorOptions {
918
+ maxBytes?: number;
919
+ }
920
+ /**
921
+ * 内容截断与二进制防护处理器
922
+ */
923
+ declare class ContentTruncator {
924
+ private defaultMaxBytes;
925
+ constructor(options?: ContentTruncatorOptions);
926
+ /**
927
+ * 智能检测 Buffer 是否为二进制数据
928
+ *
929
+ * @param buffer 输入字节流
930
+ * @return 是否为二进制数据
931
+ */
932
+ isBinary(buffer: Buffer): boolean;
933
+ /**
934
+ * 对字节流执行安全文本转换、二进制检测与防爆截断
935
+ *
936
+ * @param buffer 原始对象数据流
937
+ * @param overrideMaxBytes 可选覆盖的单次读取阈值大小
938
+ * @return 经过安全处理后的截断结果
939
+ */
940
+ process(buffer: Buffer, overrideMaxBytes?: number): ContentTruncationResult;
941
+ }
942
+
943
+ /**
944
+ * S3 连通性自省探针核心服务 (s3_ping)
945
+ *
946
+ * @author Ateng
947
+ * @since 2026-10-04
948
+ */
949
+
950
+ /**
951
+ * 执行轻量连通性自省探针诊断
952
+ *
953
+ * 向目标对象存储发起极轻量的探测请求,测试端点连通性、网络往返时延 (RTT) 并自省鉴权状态
954
+ *
955
+ * @param client S3 客户端实例
956
+ * @param config 应用全局配置
957
+ * @return 连通性诊断结果
958
+ */
959
+ declare function executeS3Ping(client: S3Client, config: AppConfig): Promise<ConnectivityProbeResult>;
960
+
961
+ /**
962
+ * 存储桶生命周期服务 (Bucket Service)
963
+ *
964
+ * 管理存储桶的列出、创建、删除及物理地域查询
965
+ *
966
+ * @author Ateng
967
+ * @since 2026-10-04
968
+ */
969
+
970
+ /**
971
+ * 查询全量存储桶列表
972
+ *
973
+ * @param client S3 客户端实例
974
+ * @return 存储桶信息数组 (无数据时返回空数组,绝不返回 null)
975
+ */
976
+ declare function listBuckets(client: S3Client): Promise<BucketItem[]>;
977
+ /**
978
+ * 创建新存储桶
979
+ *
980
+ * @param client S3 客户端实例
981
+ * @param bucket 待创建的存储桶名称
982
+ * @param region 可选部署地域 (us-east-1 以外区域需传入 LocationConstraint)
983
+ * @return 创建结果
984
+ */
985
+ declare function createBucket(client: S3Client, bucket: string, region?: string): Promise<{
986
+ success: boolean;
987
+ bucket: string;
988
+ message: string;
989
+ }>;
990
+ /**
991
+ * 删除指定存储桶 (支持 force=true 强制级联清空对象后删除)
992
+ *
993
+ * @param client S3 客户端实例
994
+ * @param bucket 待删除的存储桶名称
995
+ * @param force 是否强制清理桶内所有对象后删除
996
+ * @return 删除结果
997
+ */
998
+ declare function deleteBucket(client: S3Client, bucket: string, force?: boolean): Promise<{
999
+ success: boolean;
1000
+ bucket: string;
1001
+ message: string;
1002
+ }>;
1003
+ /**
1004
+ * 查询存储桶实际物理部署地域
1005
+ *
1006
+ * @param client S3 客户端实例
1007
+ * @param bucket 存储桶名称
1008
+ * @return 地域结果
1009
+ */
1010
+ declare function getBucketLocation(client: S3Client, bucket: string): Promise<{
1011
+ bucket: string;
1012
+ region: string;
1013
+ }>;
1014
+
1015
+ /**
1016
+ * S3 对象检索探索与内容直读服务 (Object Service)
1017
+ *
1018
+ * 提供虚拟目录树分页、关键字与正则匹配搜索、对象元数据检视、安全内存流式截断直读与 Range 范围读取
1019
+ *
1020
+ * @author Ateng
1021
+ * @since 2026-10-04
1022
+ */
1023
+
1024
+ /**
1025
+ * 解析并决议生效的存储桶名称
1026
+ *
1027
+ * @param bucket 接口显式传入的存储桶
1028
+ * @param defaultBucket 全局默认绑定的存储桶
1029
+ * @return 决议后的非空存储桶名称
1030
+ * @throws 当两者皆未指定时抛出语义化异常
1031
+ */
1032
+ declare function resolveBucket(bucket?: string, defaultBucket?: string): string;
1033
+ /**
1034
+ * 查询虚拟分层目录树与分页对象列表 (Delimiter 默认为 '/')
1035
+ *
1036
+ * @param client S3 客户端实例
1037
+ * @param params 分页查询入参
1038
+ * @param defaultBucket 默认存储桶
1039
+ * @return 虚拟目录列表与对象聚合响应
1040
+ */
1041
+ declare function listObjects(client: S3Client, params: ListObjectsInput, defaultBucket?: string): Promise<ListObjectsResult>;
1042
+ /**
1043
+ * 在前缀路径树中执行对象关键字或正则匹配搜索 (受扫描页数上限保护)
1044
+ *
1045
+ * @param client S3 客户端实例
1046
+ * @param params 搜索入参
1047
+ * @param defaultBucket 默认存储桶
1048
+ * @return 匹配的对象列表
1049
+ */
1050
+ declare function searchObjects(client: S3Client, params: SearchObjectsInput, defaultBucket?: string): Promise<S3ObjectItem[]>;
1051
+ /**
1052
+ * 获取指定对象的元数据与属性 (HeadObject)
1053
+ *
1054
+ * @param client S3 客户端实例
1055
+ * @param params 对象属性检视入参
1056
+ * @param defaultBucket 默认存储桶
1057
+ * @return 对象元数据
1058
+ */
1059
+ declare function statObject(client: S3Client, params: StatObjectInput, defaultBucket?: string): Promise<ObjectMetadata>;
1060
+ /**
1061
+ * 文本直读服务 (具备流式 OOM 防护、MIME 二进制前置拦截与编码适配)
1062
+ *
1063
+ * @param client S3 客户端实例
1064
+ * @param params 文本读取入参
1065
+ * @param truncator 截断器实例
1066
+ * @param defaultBucket 默认存储桶
1067
+ * @return 文本读取与截断结果
1068
+ */
1069
+ declare function readObjectText(client: S3Client, params: ReadObjectTextInput, truncator: ContentTruncator, defaultBucket?: string): Promise<ReadObjectTextResult>;
1070
+ /**
1071
+ * 局部字节区间读取 (Range Read)
1072
+ *
1073
+ * @param client S3 客户端实例
1074
+ * @param params 字节区间读取入参
1075
+ * @param defaultBucket 默认存储桶
1076
+ * @param truncator 可选截断器 (复用二进制判定能力)
1077
+ * @return 范围读取结果
1078
+ */
1079
+ declare function readObjectRange(client: S3Client, params: ReadObjectRangeInput, defaultBucket?: string, truncator?: ContentTruncator): Promise<RangeReadResult>;
1080
+
1081
+ /**
1082
+ * S3 双向流式文件互传服务 (Transfer Service)
1083
+ *
1084
+ * 提供文本写入覆盖、本地磁盘与 S3 双向流式互传 (受 SandboxGuard 沙箱严格约束)
1085
+ *
1086
+ * @author Ateng
1087
+ * @since 2026-10-04
1088
+ */
1089
+
1090
+ /**
1091
+ * 自动触发分段上传的单文件大小阈值 (32MB)
1092
+ */
1093
+ declare const MULTIPART_UPLOAD_THRESHOLD_BYTES: number;
1094
+ /**
1095
+ * 分段上传单分片大小 (8MB)
1096
+ */
1097
+ declare const MULTIPART_PART_SIZE_BYTES: number;
1098
+ /**
1099
+ * 分段上传并发队列大小
1100
+ */
1101
+ declare const MULTIPART_QUEUE_SIZE = 4;
1102
+ /**
1103
+ * 文本直接写入或覆盖对象
1104
+ *
1105
+ * @param client S3 客户端实例
1106
+ * @param params 文本写入入参
1107
+ * @param defaultBucket 默认存储桶
1108
+ * @return 写入操作响应结果
1109
+ */
1110
+ declare function putObjectText(client: S3Client, params: PutObjectTextInput, defaultBucket?: string): Promise<{
1111
+ success: boolean;
1112
+ bucket: string;
1113
+ key: string;
1114
+ etag?: string;
1115
+ message: string;
1116
+ }>;
1117
+ /**
1118
+ * 本地文件流式上传至 S3 (受工作区路径沙箱守卫严格约束,支持大文件透明分段上传)
1119
+ *
1120
+ * @param client S3 客户端实例
1121
+ * @param params 上传参数
1122
+ * @param sandboxGuard 沙箱守卫实例
1123
+ * @param defaultBucket 默认存储桶
1124
+ * @return 上传结果
1125
+ * @throws 当文件不存在、不是有效文件、读取流出错或沙箱越权时抛出 BusinessError 或 SecurityError
1126
+ */
1127
+ declare function uploadFile(client: S3Client, params: UploadFileInput, sandboxGuard: SandboxGuard, defaultBucket?: string): Promise<{
1128
+ success: boolean;
1129
+ bucket: string;
1130
+ key: string;
1131
+ localPath: string;
1132
+ size: number;
1133
+ message: string;
1134
+ }>;
1135
+ /**
1136
+ * S3 对象流式保存为本地文件 (受工作区路径沙箱守卫保护)
1137
+ *
1138
+ * @param client S3 客户端实例
1139
+ * @param params 下载参数
1140
+ * @param sandboxGuard 沙箱守卫实例
1141
+ * @param defaultBucket 默认存储桶
1142
+ * @return 下载结果
1143
+ * @throws 当对象内容流为空、写入磁盘失败或沙箱越权时抛出 BusinessError 或 SecurityError
1144
+ */
1145
+ declare function downloadFile(client: S3Client, params: DownloadFileInput, sandboxGuard: SandboxGuard, defaultBucket?: string): Promise<{
1146
+ success: boolean;
1147
+ bucket: string;
1148
+ key: string;
1149
+ localPath: string;
1150
+ size: number;
1151
+ message: string;
1152
+ }>;
1153
+
1154
+ /**
1155
+ * S3 预签名直链服务 (Presigned URL Service)
1156
+ *
1157
+ * 生成有时效性的 HTTP(S) 下载与上传预签名外链,支持只读门禁安全校验
1158
+ *
1159
+ * @author Ateng
1160
+ * @since 2026-10-04
1161
+ */
1162
+
1163
+ /**
1164
+ * 生成具备时效性的预签名直链 (支持下载 GET 与上传 PUT)
1165
+ *
1166
+ * @param client S3 客户端实例
1167
+ * @param params 预签名参数
1168
+ * @param readOnlyGuard 只读门禁守卫 (可选)
1169
+ * @param defaultBucket 默认存储桶
1170
+ * @param defaultExpiresIn 全局默认有效秒数
1171
+ * @return 预签名直链与配置元信息
1172
+ * @throws 当只读模式下尝试生成 PUT 上传直链时抛出 SecurityError
1173
+ */
1174
+ declare function getPresignedUrl(client: S3Client, params: GetPresignedUrlInput, readOnlyGuard?: ReadOnlyGuard, defaultBucket?: string, defaultExpiresIn?: number): Promise<{
1175
+ url: string;
1176
+ bucket: string;
1177
+ key: string;
1178
+ method: "GET" | "PUT";
1179
+ expiresIn: number;
1180
+ }>;
1181
+
1182
+ /**
1183
+ * S3 对象批处理与移动删除服务 (Batch Service)
1184
+ *
1185
+ * 提供跨桶与同桶对象复制、原子化移动重命名、单对象与千级批量删除以及前缀递归清理三重防灾熔断
1186
+ *
1187
+ * @author Ateng
1188
+ * @since 2026-10-04
1189
+ */
1190
+
1191
+ /**
1192
+ * 同桶或跨桶对象复制
1193
+ *
1194
+ * @param client S3 客户端实例
1195
+ * @param params 复制参数
1196
+ * @param defaultBucket 默认存储桶
1197
+ * @return 复制结果
1198
+ * @throws 当存储桶未指定时抛出异常
1199
+ */
1200
+ declare function copyObject(client: S3Client, params: CopyObjectInput, defaultBucket?: string): Promise<{
1201
+ success: boolean;
1202
+ sourceBucket: string;
1203
+ sourceKey: string;
1204
+ targetBucket: string;
1205
+ targetKey: string;
1206
+ message: string;
1207
+ }>;
1208
+ /**
1209
+ * 原子化移动与重命名对象 (复制成功后自动删除源对象,内置同源防自毁检测)
1210
+ *
1211
+ * @param client S3 客户端实例
1212
+ * @param params 移动参数
1213
+ * @param defaultBucket 默认存储桶
1214
+ * @return 移动结果
1215
+ * @throws 当源对象与目标对象路径完全相同时抛出 BusinessError
1216
+ */
1217
+ declare function moveObject(client: S3Client, params: MoveObjectInput, defaultBucket?: string): Promise<{
1218
+ success: boolean;
1219
+ sourceBucket: string;
1220
+ sourceKey: string;
1221
+ targetBucket: string;
1222
+ targetKey: string;
1223
+ message: string;
1224
+ }>;
1225
+ /**
1226
+ * 删除指定的单个对象
1227
+ *
1228
+ * @param client S3 客户端实例
1229
+ * @param params 删除参数
1230
+ * @param defaultBucket 默认存储桶
1231
+ * @return 删除结果
1232
+ * @throws 当存储桶未指定时抛出异常
1233
+ */
1234
+ declare function deleteObject(client: S3Client, params: DeleteObjectInput, defaultBucket?: string): Promise<{
1235
+ success: boolean;
1236
+ bucket: string;
1237
+ key: string;
1238
+ message: string;
1239
+ }>;
1240
+ /**
1241
+ * 批量删除多个指定对象 (单批上限 1000)
1242
+ *
1243
+ * @param client S3 客户端实例
1244
+ * @param params 批量删除参数
1245
+ * @param defaultBucket 默认存储桶
1246
+ * @return 批量删除结果
1247
+ * @throws 当对象键列表为空、超过上限或部分删除失败时抛出 SecurityError 或 BusinessError
1248
+ */
1249
+ declare function deleteObjectsBatch(client: S3Client, params: DeleteObjectsBatchInput, defaultBucket?: string): Promise<{
1250
+ success: boolean;
1251
+ bucket: string;
1252
+ deletedCount: number;
1253
+ message: string;
1254
+ }>;
1255
+ /**
1256
+ * 依据前缀递归清理虚拟目录树 (内置三重防灾熔断守卫与单批 1000 截断保护)
1257
+ *
1258
+ * @param client S3 客户端实例
1259
+ * @param params 前缀递归删除参数
1260
+ * @param defaultBucket 默认存储桶
1261
+ * @return 递归删除统计结果及截断标识
1262
+ * @throws 当缺少确认参数、前缀为根目录或部分删除失败时抛出 SecurityError 或 BusinessError
1263
+ */
1264
+ declare function deleteObjectsByPrefix(client: S3Client, params: DeleteObjectsByPrefixInput, defaultBucket?: string): Promise<{
1265
+ success: boolean;
1266
+ bucket: string;
1267
+ prefix: string;
1268
+ deletedCount: number;
1269
+ isTruncated: boolean;
1270
+ message: string;
1271
+ }>;
1272
+
1273
+ /**
1274
+ * S3 对象业务标签治理服务 (Tag Service)
1275
+ *
1276
+ * 提供 S3 对象的业务 Key-Value 标签查询与全量覆盖设置
1277
+ *
1278
+ * @author Ateng
1279
+ * @since 2026-10-04
1280
+ */
1281
+
1282
+ /**
1283
+ * 查询对象关联的 Key-Value 业务标签字典
1284
+ *
1285
+ * @param client S3 客户端实例
1286
+ * @param params 标签查询入参
1287
+ * @param defaultBucket 默认存储桶
1288
+ * @return 对象标签映射字典 (无标签时返回空对象)
1289
+ */
1290
+ declare function getObjectTags(client: S3Client, params: GetObjectTagsInput, defaultBucket?: string): Promise<ObjectTags>;
1291
+ /**
1292
+ * 写入或全量覆盖对象业务标签
1293
+ *
1294
+ * @param client S3 客户端实例
1295
+ * @param params 标签设置入参
1296
+ * @param defaultBucket 默认存储桶
1297
+ * @return 标签设置结果
1298
+ */
1299
+ declare function setObjectTags(client: S3Client, params: SetObjectTagsInput, defaultBucket?: string): Promise<{
1300
+ success: boolean;
1301
+ bucket: string;
1302
+ key: string;
1303
+ tags: ObjectTags;
1304
+ message: string;
1305
+ }>;
1306
+
1307
+ /**
1308
+ * 原生 HTTP SSE 服务与健康检查探针中枢 (SSE Server)
1309
+ *
1310
+ * 暴露 /sse 长轮询流式通道、/message 客户端双向交互端点以及 /health 容器存活就绪探针
1311
+ * 内置全量 CORS 跨域响应头与可选 Bearer Token 接入安全鉴权
1312
+ *
1313
+ * @author Ateng
1314
+ * @since 2026-10-04
1315
+ */
1316
+
1317
+ /**
1318
+ * MCP 服务端实例工厂类型
1319
+ */
1320
+ type McpServerFactory = () => McpServer | Promise<McpServer>;
1321
+ /**
1322
+ * SSE 服务运行实例契约
1323
+ */
1324
+ interface SSEServerInstance {
1325
+ /**
1326
+ * 底层 Node 原生 HTTP 服务实例
1327
+ */
1328
+ server: http.Server;
1329
+ /**
1330
+ * 优雅安全关闭服务器函数
1331
+ */
1332
+ close: () => Promise<void>;
1333
+ /**
1334
+ * 实际监听的端口号
1335
+ */
1336
+ port: number;
1337
+ }
1338
+ /**
1339
+ * 启动原生 HTTP SSE 传输服务并暴露探活端点
1340
+ *
1341
+ * @param serverOrFactory MCP 服务端单例实例或会话级工厂函数 (支持并发多会话隔离)
1342
+ * @param host 监听主机地址 (默认 0.0.0.0)
1343
+ * @param port 监听网络端口 (默认 8000)
1344
+ * @param apiKey 可选接入鉴权令牌 (配置后强制校验 Bearer Token 或 URL Token)
1345
+ * @return 运行中的服务实例与控制接口
1346
+ */
1347
+ declare function startSSEServer(serverOrFactory: McpServer | McpServerFactory, host?: string, port?: number, apiKey?: string): Promise<SSEServerInstance>;
1348
+
1349
+ /**
1350
+ * CLI 命令行参数解析与双模配置中枢
1351
+ *
1352
+ * 基于 Node 原生 parseArgs 提供命令行参数支持,CLI Flags 优先级高于环境变量
1353
+ *
1354
+ * @author Ateng
1355
+ * @since 2026-10-04
1356
+ */
1357
+
1358
+ /**
1359
+ * 打印命令行使用帮助信息
1360
+ */
1361
+ declare function printHelp(): void;
1362
+ /**
1363
+ * 解析并合并命令行参数与环境变量,输出最终生效的 AppConfig
1364
+ *
1365
+ * @param args 命令行参数数组 (缺省使用 process.argv.slice(2))
1366
+ * @param env 环境变量字典 (缺省使用 process.env)
1367
+ * @return 合并覆盖后的强类型应用配置
1368
+ */
1369
+ declare function resolveConfigWithCli(args?: string[], env?: NodeJS.ProcessEnv): {
1370
+ config: AppConfig;
1371
+ isHelp: boolean;
1372
+ isVersion: boolean;
1373
+ };
1374
+
1375
+ /**
1376
+ * MCP Server 核心装配入口 (Coordinator)
1377
+ *
1378
+ * @author Ateng
1379
+ * @since 2026-10-04
1380
+ */
1381
+
1382
+ declare const SERVER_VERSION = "1.0.1";
1383
+ /**
1384
+ * 组装并配置 MCP Server 实例
1385
+ *
1386
+ * @param config 应用全局配置
1387
+ * @param customClient 可选自定义 S3Client 实例 (主要用于单测与依赖注入)
1388
+ * @return 配置完成的 McpServer 实例
1389
+ */
1390
+ declare function createMCPServer(config?: AppConfig, customClient?: S3Client): McpServer;
1391
+
1392
+ /**
1393
+ * 启动 MCP 传输服务引擎 (根据配置自动分流 Stdio 或 SSE 双模,CLI Flags 优先于环境变量)
1394
+ *
1395
+ * @param customConfig 可选覆盖应用全局配置
1396
+ * @param argv 可选命令行参数 (默认 process.argv.slice(2))
1397
+ * @return 运行模式元数据与关闭句柄
1398
+ */
1399
+ declare function runServer(customConfig?: AppConfig, argv?: string[]): Promise<{
1400
+ mode: "stdio" | "sse";
1401
+ close?: () => Promise<void>;
1402
+ }>;
1403
+
1404
+ export { type AppConfig, AppConfigSchema, type BucketItem, BusinessError, type CommonPrefixItem, type ConnectivityProbeResult, ConnectivityProbeResultSchema, type ContentTruncationResult, ContentTruncator, type ContentTruncatorOptions, type CopyObjectInput, CopyObjectSchema, type CreateBucketInput, CreateBucketSchema, DEFAULT_MAX_READ_BYTES, type DeleteBucketInput, DeleteBucketSchema, type DeleteObjectInput, DeleteObjectSchema, type DeleteObjectsBatchInput, DeleteObjectsBatchSchema, type DeleteObjectsByPrefixInput, DeleteObjectsByPrefixSchema, type DownloadFileInput, DownloadFileSchema, type ErrorResult, ErrorResultSchema, type GetBucketLocationInput, GetBucketLocationSchema, type GetObjectTagsInput, GetObjectTagsSchema, type GetPresignedUrlInput, GetPresignedUrlSchema, type ListBucketsInput, ListBucketsSchema, type ListObjectsInput, type ListObjectsResult, ListObjectsSchema, MULTIPART_PART_SIZE_BYTES, MULTIPART_QUEUE_SIZE, MULTIPART_UPLOAD_THRESHOLD_BYTES, type McpServerFactory, type MoveObjectInput, MoveObjectSchema, type ObjectMetadata, type ObjectTags, PrefixDeletionGuard, type PresignedUrlResult, type PutObjectTextInput, PutObjectTextSchema, type RangeReadResult, type ReadObjectRangeInput, ReadObjectRangeSchema, type ReadObjectTextInput, type ReadObjectTextResult, ReadObjectTextSchema, ReadOnlyGuard, type S3ClientConfig, S3ClientConfigSchema, type S3CredentialsConfig, S3CredentialsConfigSchema, type S3ObjectItem, type S3PingInput, S3PingSchema, SERVER_VERSION, type SSEServerInstance, SandboxGuard, type SearchObjectsInput, SearchObjectsSchema, type SecurityCheckResult, SecurityError, type SecurityErrorCode, SecurityErrorCodeSchema, type SetObjectTagsInput, SetObjectTagsSchema, type StatObjectInput, StatObjectSchema, type TagItem, type TransportMode, TransportModeSchema, type UploadFileInput, UploadFileSchema, copyObject, createBucket, createMCPServer, createS3Client, deleteBucket, deleteObject, deleteObjectsBatch, deleteObjectsByPrefix, downloadFile, executeS3Ping, findSafeUtf8CutPoint, getBucketLocation, getEnvValue, getObjectTags, getPresignedUrl, getS3Client, getS3ClientConfig, listBuckets, listObjects, maskAccessKey, maskSensitiveConfig, moveObject, parseBoolean, parseEnv, parseNumber, parsePort, parsePositiveInt, printHelp, putObjectText, readObjectRange, readObjectText, resetS3Client, resolveBucket, resolveConfigWithCli, runServer, searchObjects, setObjectTags, startSSEServer, statObject, uploadFile };