s3_read_object
Retrieve content from an S3-compatible storage bucket by specifying the bucket name and object key path.
Instructions
Read the content of an object from an S3 bucket
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucket | Yes | The name of the bucket | |
| key | Yes | The key (path) of the object |
Implementation Reference
- src/index.ts:198-217 (handler)The handler for the s3_read_object tool. Extracts bucket and key from arguments, sends GetObjectCommand to S3 client, converts response body stream to string using streamToString helper, and returns the content as text.case "s3_read_object": { const { bucket, key } = request.params.arguments as { bucket: string; key: string; }; const command = new GetObjectCommand({ Bucket: bucket, Key: key, }); const response = await s3Client.send(command); const body = await streamToString(response.Body); return { content: [ { type: "text", text: body, }, ], }; }
- src/index.ts:96-109 (schema)Input schema definition for s3_read_object tool, specifying bucket and key as required string parameters.inputSchema: { type: "object", properties: { bucket: { type: "string", description: "The name of the bucket", }, key: { type: "string", description: "The key (path) of the object", }, }, required: ["bucket", "key"], },
- src/index.ts:93-110 (registration)Registration of the s3_read_object tool in the listTools response, including name, description, and input schema.{ name: "s3_read_object", description: "Read the content of an object from an S3 bucket", inputSchema: { type: "object", properties: { bucket: { type: "string", description: "The name of the bucket", }, key: { type: "string", description: "The key (path) of the object", }, }, required: ["bucket", "key"], }, },
- src/index.ts:52-58 (helper)Helper utility to convert S3 GetObject response stream to a string, specifically used in the s3_read_object handler.const streamToString = (stream: any): Promise<string> => new Promise((resolve, reject) => { const chunks: any[] = []; stream.on("data", (chunk: any) => chunks.push(chunk)); stream.on("error", reject); stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8"))); });