Skip to main content
Glama
lithtrix

lithtrix-mcp

Official

lithtrix_blob_upload

Upload binary bytes to blob storage by providing base64-encoded content and a MIME type. Optionally specify a display filename.

Instructions

Upload binary bytes via PUT /v1/blobs (raw body + Content-Type). Decode base64 from content_base64. For large files prefer direct HTTP multipart/raw PUT. Requires LITHTRIX_API_KEY. Subject to BLOB_MAX_UPLOAD_BYTES and BLOB_STORAGE_LIMIT.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
content_base64YesStandard base64-encoded file bytes (no data: URL prefix)
content_typeYesMIME type sent as Content-Type (e.g. application/pdf)
filenameNoOptional display filename (sent as filename query on the request)

Implementation Reference

  • tools/blobs.js:133-192 (registration)
    The registerBlobTools function is called from index.js (line 48) to register all blob tools. Line 134 starts the registration of 'lithtrix_blob_upload' tool on the MCP server via server.tool().
    export function registerBlobTools(server) {
      server.tool(
        "lithtrix_blob_upload",
        "Upload binary bytes via PUT /v1/blobs (raw body + Content-Type). " +
          "Decode base64 from content_base64. For large files prefer direct HTTP multipart/raw PUT. " +
          "Requires LITHTRIX_API_KEY. Subject to BLOB_MAX_UPLOAD_BYTES and BLOB_STORAGE_LIMIT.",
        {
          content_base64: z
            .string()
            .min(1)
            .describe("Standard base64-encoded file bytes (no data: URL prefix)"),
          content_type: z
            .string()
            .min(1)
            .max(255)
            .describe("MIME type sent as Content-Type (e.g. application/pdf)"),
          filename: z
            .string()
            .max(512)
            .optional()
            .describe("Optional display filename (sent as filename query on the request)"),
        },
        async ({ content_base64, content_type, filename }) => {
          const apiKey = process.env.LITHTRIX_API_KEY;
          if (!apiKey) return missingApiKeyResponse();
    
          let binary;
          try {
            binary = Buffer.from(content_base64, "base64");
          } catch (err) {
            return {
              content: [
                {
                  type: "text",
                  text: JSON.stringify({ error: `Invalid base64: ${err.message}` }),
                },
              ],
              isError: true,
            };
          }
    
          const url = new URL("/v1/blobs", LITHTRIX_API_URL);
          if (filename !== undefined) url.searchParams.set("filename", filename);
    
          let response;
          try {
            response = await fetch(url.toString(), {
              method: "PUT",
              headers: {
                Authorization: `Bearer ${apiKey}`,
                "Content-Type": content_type,
              },
              body: binary,
            });
          } catch (err) {
            return networkErrorResponse(err);
          }
          return apiJsonResponse(response);
        }
      );
  • The async handler function that executes 'lithtrix_blob_upload': decodes base64 from content_base64, sends PUT /v1/blobs with the binary body and Content-Type, and returns the API JSON response.
    async ({ content_base64, content_type, filename }) => {
      const apiKey = process.env.LITHTRIX_API_KEY;
      if (!apiKey) return missingApiKeyResponse();
    
      let binary;
      try {
        binary = Buffer.from(content_base64, "base64");
      } catch (err) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({ error: `Invalid base64: ${err.message}` }),
            },
          ],
          isError: true,
        };
      }
    
      const url = new URL("/v1/blobs", LITHTRIX_API_URL);
      if (filename !== undefined) url.searchParams.set("filename", filename);
    
      let response;
      try {
        response = await fetch(url.toString(), {
          method: "PUT",
          headers: {
            Authorization: `Bearer ${apiKey}`,
            "Content-Type": content_type,
          },
          body: binary,
        });
      } catch (err) {
        return networkErrorResponse(err);
      }
      return apiJsonResponse(response);
    }
  • Zod schema definitions for the tool's input parameters: content_base64 (base64 string), content_type (MIME type), and optional filename (display name, sent as query param).
    {
      content_base64: z
        .string()
        .min(1)
        .describe("Standard base64-encoded file bytes (no data: URL prefix)"),
      content_type: z
        .string()
        .min(1)
        .max(255)
        .describe("MIME type sent as Content-Type (e.g. application/pdf)"),
      filename: z
        .string()
        .max(512)
        .optional()
        .describe("Optional display filename (sent as filename query on the request)"),
    },
  • Helper function missingApiKeyResponse() used when LITHTRIX_API_KEY is not set.
    function missingApiKeyResponse() {
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({
              error:
                "LITHTRIX_API_KEY environment variable is not set. " +
                "Register at https://lithtrix.ai and use lithtrix_register, then set the key.",
            }),
          },
        ],
        isError: true,
      };
    }
  • Helper function apiJsonResponse() that processes the API response, handling errors and returning JSON content.
    async function apiJsonResponse(response) {
      let body;
      try {
        body = await response.json();
      } catch {
        body = { message: `Invalid JSON (HTTP ${response.status})` };
      }
    
      if (!response.ok) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({
                error: body.message ?? `Lithtrix API error (HTTP ${response.status})`,
                error_code: body.error_code ?? "UNKNOWN",
                status: body.status,
              }),
            },
          ],
          isError: true,
        };
      }
    
      return {
        content: [{ type: "text", text: JSON.stringify(body, null, 2) }],
      };
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that this is an upload operation that decodes base64, requires API key, and is subject to size limits. However, it lacks detail about the response format, side effects (e.g., whether it creates or overwrites), and error conditions. This is a moderate disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three sentences, each adding distinct value: purpose, decoding explanation, alternative for large files and requirements. No fluff, front-loaded with key action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no output schema, the description omits return value info (e.g., blob ID or URL). It covers main points but leaves a gap in what the agent can expect as a response. The mention of limits is useful. Somewhat complete but could be improved.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 3 parameters with 100% description coverage. The description adds value by explaining base64 decoding and mentioning the raw body + Content-Type, which relates to the content_type parameter. It also references storage limits, though not explicitly tied to parameters. This supplements the schema well.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action: 'Upload binary bytes via PUT /v1/blobs', specifying verb and resource. It distinguishes from siblings like lithtrix_blob_delete, lithtrix_blob_download, etc., which are different operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides guidance: 'For large files prefer direct HTTP multipart/raw PUT', hinting at an alternative approach for efficiency. It also mentions requirements like API key and subject to limits. However, it does not explicitly contrast with sibling tools (none are upload-focused) or state when not to use this tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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/lithtrix/lithtrix-mcp'

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