Skip to main content
Glama

get-object

Retrieve a specific object from an S3 bucket by providing the bucket name and object key. Use this tool to access and manage storage content within AWS S3 through the S3 MCP Server.

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 main handler function that implements the get-object tool logic. It retrieves the object from the specified S3 bucket and key using s3Resource.getObject, handles text and binary content differently, and returns formatted MCP 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)}`, ); } }
  • Zod schema defining the input parameters for the get-object tool: bucket name and object key.
    readonly parameters = { bucket: z.string().describe("Name of the S3 bucket"), key: z.string().describe("Key (path) of the object to retrieve"), } as const;
  • Instantiation of the GetObjectTool class instance within the createTools function, which collects all tool instances.
    new GetObjectTool(s3Resource),
  • src/server.ts:27-31 (registration)
    Registration of all tools, including get-object, on the MCP server by calling server.tool() with the tool's name, description, parameters, and bound execute method.
    // 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)); }
  • Declaration of the tool name as 'get-object', used during MCP registration.
    readonly name = "get-object";

Other Tools

Related 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