Skip to main content
Glama
akave-ai

Akave MCP Server

by akave-ai

get_object

Retrieve object content from an S3-compatible storage bucket by specifying the bucket name and object key, enabling access to stored files and data.

Instructions

Get object content from a bucket

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucketYesBucket name
keyYesObject key

Implementation Reference

  • The handler function for the 'get_object' MCP tool. Retrieves object using S3Client.getObject, handles errors, formats content as text, with special trimming for markdown files.
    async ({ bucket, key }: GetObjectParams) => { const object = await this.s3Client.getObject(bucket, key); if (!object) { return { content: [ { type: "text", text: "Object not found", }, ], isError: true, }; } // Ensure we're returning a proper string let content = typeof object === "string" ? object : JSON.stringify(object); // For markdown files, ensure proper formatting if (key.endsWith(".md")) { // Remove any potential BOM or special characters content = content.replace(/^\uFEFF/, "").trim(); } return { content: [ { type: "text", text: content, }, ], }; }
  • Zod input schema for the get_object tool defining required parameters bucket and key.
    bucket: z.string().describe("Bucket name"), key: z.string().describe("Object key"), },
  • src/server.ts:93-99 (registration)
    Registration of the 'get_object' tool on the MCP server, including name, description, and input schema.
    this.server.tool( "get_object", "Get object content from a bucket", { bucket: z.string().describe("Bucket name"), key: z.string().describe("Object key"), },
  • TypeScript type definition for GetObjectParams used to type the handler input.
    interface GetObjectParams { bucket: string; key: string; }
  • Core helper method in S3Client that executes the AWS GetObjectCommand, streams and converts body to UTF-8 text, cleans content for text files, prettifies JSON, handles errors.
    async getObject(bucket: string, key: string) { try { const command = new GetObjectCommand({ Bucket: bucket, Key: key, }); const response = await this.client.send(command); if (!response.Body) { return null; } // Convert the response body to string const bodyStream = response.Body as any; const chunks: Uint8Array[] = []; for await (const chunk of bodyStream) { chunks.push(chunk); } const buffer = Buffer.concat(chunks); const text = buffer.toString("utf-8"); // Handle different file types const extension = key.split(".").pop()?.toLowerCase(); // Text-based files that should be cleaned const textFileExtensions = [ "md", "txt", "json", "yaml", "yml", "xml", "html", "css", "js", "ts", "py", "sh", "bash", ]; if (textFileExtensions.includes(extension || "")) { // Clean the text content const cleanedText = text .replace(/^\uFEFF/, "") // Remove BOM .trim(); // Remove extra whitespace // Special handling for JSON files if (extension === "json") { try { // Validate and format JSON const parsed = JSON.parse(cleanedText); return JSON.stringify(parsed, null, 2); } catch { // If JSON parsing fails, return as is return cleanedText; } } return cleanedText; } // For binary or unknown file types, return as is return text; } catch (error) { console.error("Error getting object:", error); return null; } }

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/akave-ai/akave-mcp'

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