Skip to main content
Glama
apitable

AITable MCP Server

Official

upload_attachment_via_url

Upload files to the AITable server using a web URL. Store file data for attaching to specific records via create_record or update_record tools.

Instructions

Upload an attachment to the AITable server using its web URL. Returns storage information that can be passed to create_record or update_record tools to associate with a specific records.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
attachment_nameNoOptional custom name for the attachment after upload.
attachment_urlYesThe complete web URL of the file to be uploaded.
node_idYesThe ID of the datasheet where the attachment will be attached after upload.

Implementation Reference

  • src/index.ts:287-323 (registration)
    Registration of the 'upload_attachment_via_url' tool using server.tool(), including description, input schema, and handler function.
    server.tool("upload_attachment_via_url",
      "Upload an attachment to the AITable server using its web URL. Returns storage information that can be passed to create_record or update_record tools to associate with a specific records.",
      {
        node_id: z.string().describe('The ID of the datasheet where the attachment will be attached after upload.'),
        attachment_url: z.string().describe('The complete web URL of the file to be uploaded.'),
        attachment_name: z.string().optional().describe('Optional custom name for the attachment after upload.'),
      },
      async ({ node_id, attachment_url, attachment_name }) => {
        try {
          if (!node_id) {
            throw new Error("The datasheet ID (node_id) is required.");
          }
    
          if (!attachment_url) {
            throw new Error("The attachment URL is required.");
          }
    
          const result: ResponseVO<attachmentVO[]> = await aitableService.uploadFileToSpace(node_id, attachment_url, attachment_name);
    
          if (!result.success) {
            throw new Error(result.message || "Failed to upload attachment");
          }
    
          return formatToolResponse({
            success: true,
            data: result
          });
        }
        catch (error) {
          console.error("Error in upload_attachment_via_url:", error);
          return formatToolResponse({
            success: false,
            message: error instanceof Error ? error.message : "Unknown error occurred"
          }, true);
        }
      }
    );
  • The handler function for the tool that performs input validation and delegates to AitableService.uploadFileToSpace for the upload logic.
    async ({ node_id, attachment_url, attachment_name }) => {
      try {
        if (!node_id) {
          throw new Error("The datasheet ID (node_id) is required.");
        }
    
        if (!attachment_url) {
          throw new Error("The attachment URL is required.");
        }
    
        const result: ResponseVO<attachmentVO[]> = await aitableService.uploadFileToSpace(node_id, attachment_url, attachment_name);
    
        if (!result.success) {
          throw new Error(result.message || "Failed to upload attachment");
        }
    
        return formatToolResponse({
          success: true,
          data: result
        });
      }
      catch (error) {
        console.error("Error in upload_attachment_via_url:", error);
        return formatToolResponse({
          success: false,
          message: error instanceof Error ? error.message : "Unknown error occurred"
        }, true);
      }
    }
  • Zod input schema defining the tool parameters: node_id (required string), attachment_url (required string), attachment_name (optional string).
    {
      node_id: z.string().describe('The ID of the datasheet where the attachment will be attached after upload.'),
      attachment_url: z.string().describe('The complete web URL of the file to be uploaded.'),
      attachment_name: z.string().optional().describe('Optional custom name for the attachment after upload.'),
    },
  • Core helper method in AitableService that implements the file upload: fetches file from URL as Blob, creates FormData, POSTs to AITable /attachments endpoint.
    public async uploadFileToSpace(
      node_id: string,
      file_url: string,
      file_name?: string,
    ): Promise<ResponseVO<attachmentVO[]>> {
    
      // get the file name from file_url if not provided
      if(!file_name) {
        const url = new URL(file_url);
        file_name = url.pathname.split("/").pop() ?? "file_"+new Date().getTime();
      }
    
      // Fetch the file from the provided URL
      const fileBlob = await this._fetchFileViaURL(file_url);
      const formData = new FormData();
      formData.append("file", fileBlob, file_name);
    
      const endpoint = `/v1/datasheets/${node_id}/attachments`;
    
      const response =  await this.fetch(`${this.baseUrl}${endpoint}`, {
        headers: {
          Authorization: `Bearer ${this.apiKey}`,
        },
        body: formData,
        method: "POST",
      });
    
      const responseJson = (await response.json()) as ResponseVO<attachmentVO[]>;
    
      if (!response.ok) {
        throw new Error(
          `AITable API Error: ${response.statusText}. Response: ${responseJson.message}`
        );
      }
    
      return responseJson;
    }
  • Private helper method to fetch the remote file as a Blob from the provided URL.
    private async _fetchFileViaURL(file_url: string): Promise<Blob> {
      if (!file_url) {
        throw new Error("file_url is required.");
      }
      const response = await this.fetch(file_url)
    
      if (!response.ok) {
        throw new Error(
          `Fetch file error: ${response.statusText}. Response: ${await response.text()}`
        );
      }
    
      return response.blob();
    }
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 the tool performs an upload (implying a write operation) and returns storage information, but lacks details on permissions required, rate limits, error conditions, or what happens if the URL is invalid. For a mutation tool with zero annotation coverage, this is a moderate gap.

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 appropriately sized with two sentences that are front-loaded and efficient. The first sentence states the purpose, and the second explains the return value and usage context, with zero wasted words.

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?

Given the tool's complexity (a mutation with 3 parameters), no annotations, and no output schema, the description is moderately complete. It covers the purpose and usage context but lacks details on behavioral aspects like authentication needs, error handling, or return format specifics, which are important for a tool with no structured output.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all three parameters (attachment_name, attachment_url, node_id) with clear descriptions. The description adds no additional parameter semantics beyond what the schema provides, such as format examples or constraints, meeting the baseline score of 3.

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 specific action ('Upload an attachment') and resource ('to the AITable server using its web URL'), distinguishing it from sibling tools like create_record or update_record. It explicitly mentions the upload mechanism (via URL) and the purpose (to get storage information for record association).

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 clear context by stating that the tool returns storage information that can be passed to create_record or update_record tools, indicating when to use it (as a precursor to those operations). However, it doesn't explicitly state when NOT to use it or mention alternatives for attachment handling, such as direct file uploads if available.

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

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/apitable/aitable-mcp-server'

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