fetch_headers
Retrieve headers and metadata for a specific object stored in an S3-compatible bucket, providing essential information about the object's properties without downloading its content.
Instructions
Fetch headers/metadata for an object
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucket | Yes | Bucket name | |
| key | Yes | Object key |
Implementation Reference
- src/server.ts:203-208 (handler)The MCP tool handler for 'fetch_headers' which invokes the S3 client's fetchHeaders method and formats the response as MCP content.async ({ bucket, key }) => { const headers = await this.s3Client.fetchHeaders(bucket, key); return { content: [{ type: "text", text: JSON.stringify(headers) }], }; }
- src/server.ts:199-202 (schema)Zod input schema defining the parameters for the 'fetch_headers' tool: bucket and key.{ bucket: z.string().describe("Bucket name"), key: z.string().describe("Object key"), },
- src/server.ts:196-209 (registration)Registration of the 'fetch_headers' MCP tool including name, description, schema, and handler function.this.server.tool( "fetch_headers", "Fetch headers/metadata for an object", { bucket: z.string().describe("Bucket name"), key: z.string().describe("Object key"), }, async ({ bucket, key }) => { const headers = await this.s3Client.fetchHeaders(bucket, key); return { content: [{ type: "text", text: JSON.stringify(headers) }], }; } );
- src/s3Client.ts:132-138 (helper)Helper function in S3Client that performs a HeadObjectCommand to retrieve object metadata/headers.async fetchHeaders(bucket: string, key: string) { const command = new HeadObjectCommand({ Bucket: bucket, Key: key, }); return await this.client.send(command); }