Skip to main content
Glama

get-object

Retrieve objects from Amazon S3 buckets using bucket name and object key to access stored files and data.

Instructions

Retrieve an object from an S3 bucket

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucketYesName of the S3 bucket
keyYesKey (path) of the object to retrieve

Implementation Reference

  • The execute method implements the core logic of the get-object tool: retrieves the S3 object using the injected S3Resource, handles text and binary content, and returns MCP-formatted content or error response.
    async execute(args: InferZodParams<typeof this.parameters>) { const { bucket, key } = args; try { const result = await this.s3Resource.getObject(bucket, key); // For text content, return as text if (typeof result.data === "string") { return { content: [ { type: "text" as const, text: result.data, }, ], }; } // For binary content, return as base64-encoded string return { content: [ { type: "text" as const, text: `Binary content (${result.contentType}): base64 data is ${result.data.toString("base64").substring(0, 100)}...`, }, ], }; } catch (error) { return createErrorResponse( error, `Error getting object ${key} from bucket ${bucket}: ${error instanceof Error ? error.message : String(error)}`, ); } }
  • Tool metadata: name, description, and Zod-based input schema for bucket and key parameters.
    readonly name = "get-object"; /** * Tool description */ readonly description = "Retrieve an object from an S3 bucket"; /** * Parameter definition */ readonly parameters = { bucket: z.string().describe("Name of the S3 bucket"), key: z.string().describe("Key (path) of the object to retrieve"), } as const;
  • Factory function that instantiates and returns all tools, including the GetObjectTool with injected S3Resource.
    export function createTools(s3Resource: S3Resource): IMCPTool[] { return [ new ListBucketsTool(s3Resource), new ListObjectsTool(s3Resource), new GetObjectTool(s3Resource), ]; }
  • src/server.ts:27-31 (registration)
    Calls createTools to get tool instances and registers each on the MCP server via server.tool(name, description, parameters, execute).
    // Create and register all tools const tools = createTools(s3Resource); for (const tool of tools) { server.tool(tool.name, tool.description, tool.parameters, tool.execute.bind(tool)); }

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/samuraikun/aws-s3-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server