Skip to main content
Glama
apitable

AITable MCP Server

Official

get_fields_schema

Retrieve the JSON schema of all fields in a specified database to provide AI models with the expected data structure for accurate processing and analysis.

Instructions

Returns the JSON schema of all fields within the specified database, This schema will be sent to LLM to help the AI understand the expected structure of the data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
node_idYesThe ID of the database to fetch records from.

Implementation Reference

  • src/index.ts:182-213 (registration)
    Registration of the 'get_fields_schema' MCP tool, including description, input schema, and inline handler function that delegates to AitableService helpers.
    server.tool("get_fields_schema",
      "Returns the JSON schema of all fields within the specified database, This schema will be sent to LLM to help the AI understand the expected structure of the data.",
      {
        node_id: z.string().describe('The ID of the database to fetch records from.'),
      },
      async ({ node_id }) => {
        try {
          if (!node_id) {
            throw new Error("The datasheet ID (node_id) is required.");
          }
          const result = await aitableService.getDatasheetFieldsSchema(node_id);
    
          if (!result.success) {
            throw new Error(result.message || "Failed to fetch datasheet fields schema");
          }
    
          const fieldsSchema: FieldFormatJSONSchema = aitableService.getFieldsJSONSchema(result.data.fields);
    
          return formatToolResponse({
            success: true,
            data: fieldsSchema
          });
        }
        catch (error) {
          console.error("Error in list_database_fields:", error);
          return formatToolResponse({
            success: false,
            message: error instanceof Error ? error.message : "Unknown error occurred"
          }, true);
        }
      }
    );
  • Core handler logic for executing the tool: validates input, fetches raw fields schema from API via service, formats into LLM-compatible JSON schema, and returns standardized tool response.
    async ({ node_id }) => {
      try {
        if (!node_id) {
          throw new Error("The datasheet ID (node_id) is required.");
        }
        const result = await aitableService.getDatasheetFieldsSchema(node_id);
    
        if (!result.success) {
          throw new Error(result.message || "Failed to fetch datasheet fields schema");
        }
    
        const fieldsSchema: FieldFormatJSONSchema = aitableService.getFieldsJSONSchema(result.data.fields);
    
        return formatToolResponse({
          success: true,
          data: fieldsSchema
        });
      }
      catch (error) {
        console.error("Error in list_database_fields:", error);
        return formatToolResponse({
          success: false,
          message: error instanceof Error ? error.message : "Unknown error occurred"
        }, true);
      }
    }
  • Input validation schema using Zod, requiring a single 'node_id' string parameter.
    {
      node_id: z.string().describe('The ID of the database to fetch records from.'),
    },
  • Helper method in AitableService that performs the API call to retrieve the raw fields schema from the AITable '/v1/datasheets/{node_id}/fields' endpoint.
    public async getDatasheetFieldsSchema(
      node_id: string
    ): Promise<ResponseVO<{fields: FieldSchemaVO[]}>> {
      if (!node_id) {
        throw new Error("The datasheet ID (node_id) is required.");
      }
    
      const endpoint = `/v1/datasheets/${node_id}/fields`;
    
      return this.fetchFromAPI(endpoint, {
        method: "GET",
      });
    }
  • Helper method that transforms raw FieldSchemaVO[] into a structured JSON schema (FieldFormatJSONSchema) suitable for LLM structured outputs, mapping field types to appropriate Zod/JSON schema keywords.
    public getFieldsJSONSchema(fields: FieldSchemaVO[]): FieldFormatJSONSchema {
      const schema: {
        type: string;
        properties: Record<string, unknown>;
        additionalProperties: boolean;
        required: string[];
      } = {
        type: "object",
        properties: {},
        additionalProperties: false,
        required: [],
      };
    
      fields.forEach((field) => {
        const keywordsForField = this._getKeywordByFieldType(field);
    
        // If the field type is not supported, we skip it
        if (keywordsForField) {
          schema.properties[field.name] = keywordsForField;
          schema.required.push(field.name);
        }
      });
    
      return {
        type: "json_schema",
        json_schema: {
          name: "fields_in_datasheet",
          schema,
          strict: true,
        },
      };
    }
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 returns a JSON schema and its purpose for LLM understanding, which is useful behavioral context. However, it does not mention potential side effects, error conditions, or performance aspects (e.g., if it's a read-only operation, though implied by 'Returns'), leaving gaps in behavioral traits.

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

Conciseness4/5

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

The description is concise with two sentences that directly state the tool's function and its intended use. It is front-loaded with the core purpose, and the second sentence adds value by explaining the context for LLM integration. There is minimal waste, though it could be slightly more structured for clarity.

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 is low (single parameter, no output schema), the description is somewhat complete by explaining the return type and purpose. However, it lacks details on output format, error handling, or integration with sibling tools, which could enhance completeness. Without annotations or output schema, it provides basic but not thorough contextual coverage.

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?

The input schema has 100% description coverage, with 'node_id' documented as 'The ID of the database to fetch records from.' The description adds no additional parameter details beyond this, such as format examples or constraints. Since schema coverage is high, the baseline score of 3 is appropriate, as the description does not compensate but also does not detract.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Returns the JSON schema of all fields within the specified database.' It specifies the verb ('Returns') and resource ('JSON schema of all fields'), making the function evident. However, it does not explicitly differentiate from sibling tools like 'search_nodes' or 'list_spaces', which might also involve database interactions, so it misses full sibling distinction.

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

Usage Guidelines3/5

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

The description implies usage by stating the schema 'will be sent to LLM to help the AI understand the expected structure of the data,' suggesting it's for data structure comprehension. However, it lacks explicit guidance on when to use this tool versus alternatives (e.g., 'list_records' for actual data or 'search_nodes' for node details), and does not mention prerequisites or exclusions, leaving usage context somewhat vague.

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