Skip to main content
Glama
cheungxin

JianDaoYun MCP Server

by cheungxin

query_form_data

Retrieve form data entries from JianDaoYun with filtering, pagination, and field selection for targeted data analysis.

Instructions

Query multiple form data entries with filtering support

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appIdYesThe JianDaoYun application ID
appKeyNoThe JianDaoYun application key (API key) (optional, will use JIANDAOYUN_APP_KEY from environment if not provided)
formIdYesThe form ID (can be form ID or app ID)
dataIdNoLast data ID for pagination
fieldsNoFields to return (widget IDs)
filterNoData filter conditions
limitNoNumber of records to return (1-100, default: 10)

Implementation Reference

  • Core handler implementation in JianDaoYunClient class. Performs the API POST request to '/v5/app/entry/data/list' with parameters for formId, pagination (dataId, limit), field selection, and filtering. Handles errors and returns the data.
    async queryFormData(options: QueryDataOptions): Promise<any> {
      try {
        const requestData: any = {
          app_id: this.config.appId,
          entry_id: options.formId,
          limit: options.limit || 10
        };
    
        if (options.dataId) {
          requestData.data_id = options.dataId;
        }
    
        if (options.fields && options.fields.length > 0) {
          requestData.fields = options.fields;
        }
    
        if (options.filter) {
          requestData.filter = options.filter;
        }
    
        const response = await this.axios.post<ApiResponse>('/v5/app/entry/data/list', requestData);
    
        if (response.data.code !== 0) {
          throw new Error(`Failed to query form data: ${response.data.msg}`);
        }
    
        return response.data.data;
      } catch (error) {
        if (axios.isAxiosError(error)) {
          throw new Error(`API request failed: ${error.response?.data?.msg || error.message}`);
        }
        throw error;
      }
    }
  • MCP server tool handler for 'query_form_data'. Validates parameters, resolves formId intelligently (appId or formId), instantiates JianDaoYunClient, calls its queryFormData method, formats response, and handles errors.
    case 'query_form_data': {
      const { formId, dataId, fields, filter, limit } = args as {
        formId: string;
        dataId?: string;
        fields?: string[];
        filter?: any;
        limit?: number;
      };
      const { appId, appKey, baseUrl } = getDefaultParams(args);
      
      // 验证必需参数
      if (!appKey) {
        throw new Error('appKey is required. Please set JIANDAOYUN_APP_KEY in MCP server configuration.');
      }
      if (!appId) {
        throw new Error('appId is required. Please provide it as parameter.');
      }
    
      try {
        // 创建客户端实例
        const jdyClient = new JianDaoYunClient({
          appId,
          appKey,
          baseUrl
        });
        
        const resolved = await resolveFormId(formId, appKey);
        const result = await jdyClient.queryFormData({
          formId: resolved.formId,
          dataId,
          fields,
          filter,
          limit,
        });
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                ...result,
                formUsed: resolved.formId,
                appId: resolved.appId || appId
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        throw createEnhancedError(error, '查询表单数据');
      }
    }
  • Tool schema definition returned by listTools, including detailed inputSchema with properties for appId, appKey, formId, pagination, fields, filter conditions, and limit validation.
    {
      name: 'query_form_data',
      description: 'Query multiple form data entries with filtering support',
      inputSchema: {
        type: 'object',
        properties: {
          appId: {
            type: 'string',
            description: 'The JianDaoYun application ID',
          },
          appKey: {
            type: 'string',
            description: 'The JianDaoYun application key (API key) (optional, will use JIANDAOYUN_APP_KEY from environment if not provided)',
          },
          formId: {
            type: 'string',
            description: 'The form ID (can be form ID or app ID)',
          },
          dataId: {
            type: 'string',
            description: 'Last data ID for pagination',
          },
          fields: {
            type: 'array',
            items: { type: 'string' },
            description: 'Fields to return (widget IDs)',
          },
          filter: {
            type: 'object',
            description: 'Data filter conditions',
            properties: {
              rel: {
                type: 'string',
                enum: ['and', 'or'],
                description: 'Relation between conditions',
              },
              cond: {
                type: 'array',
                description: 'Filter conditions',
                items: {
                  type: 'object',
                  properties: {
                    field: { type: 'string' },
                    type: { type: 'string' },
                    method: { type: 'string' },
                    value: {},
                  },
                  required: ['field', 'method'],
                },
              },
            },
            required: ['rel', 'cond'],
          },
          limit: {
            type: 'number',
            description: 'Number of records to return (1-100, default: 10)',
            minimum: 1,
            maximum: 100,
          },
        },
        required: ['appId', 'formId'],
      },
    },
  • TypeScript interface definitions for QueryDataOptions, DataFilter, and FilterCondition used in the queryFormData method signature and filter handling.
    export interface QueryDataOptions {
      formId: string;
      dataId?: string;
      fields?: string[];
      filter?: DataFilter;
      limit?: number;
    }
    
    export interface DataFilter {
      rel: 'and' | 'or';
      cond: FilterCondition[];
    }
    
    export interface FilterCondition {
      field: string;
      type?: string;
      method: 'eq' | 'ne' | 'in' | 'nin' | 'range' | 'empty' | 'not_empty' | 'like' | 'verified' | 'unverified';
      value?: any;
    }
  • src/index.ts:244-507 (registration)
    Registration of the query_form_data tool in the MCP server's listTools handler, including it in the tools array.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: 'get_form_fields',
            description: 'Get field definitions for a JianDaoYun form',
            inputSchema: {
              type: 'object',
              properties: {
                appId: {
                  type: 'string',
                  description: 'The JianDaoYun application ID',
                },
                appKey: {
                  type: 'string',
                  description: 'The JianDaoYun application key (API key) (can be provided via JIANDAOYUN_APP_KEY environment variable)',
                },
                formId: {
                  type: 'string',
                  description: 'The form ID to query fields for (can be form ID or app ID)',
                },
              },
              required: ['appId', 'formId'],
            },
          },
          {
            name: 'submit_form_data',
            description: 'Submit data to a JianDaoYun form with automatic field type matching',
            inputSchema: {
              type: 'object',
              properties: {
                appId: {
                  type: 'string',
                  description: 'The JianDaoYun application ID',
                },
                appKey: {
                  type: 'string',
                  description: 'The JianDaoYun application key (API key) (optional, will use JIANDAOYUN_APP_KEY from environment if not provided)',
                },
                formId: {
                  type: 'string',
                  description: 'The form ID to submit data to (can be form ID or app ID)',
                },
                data: {
                  type: ['object', 'array'],
                  description: 'The data to submit (single object or array for batch)',
                },
                autoMatch: {
                  type: 'boolean',
                  description: 'Whether to automatically match field types (default: true)',
                  default: true,
                },
                transactionId: {
                  type: 'string',
                  description: 'Optional transaction ID for idempotent submissions',
                },
              },
              required: ['appId', 'formId', 'data'],
            },
          },
          {
            name: 'get_form_data',
            description: 'Get a specific data entry from a JianDaoYun form',
            inputSchema: {
              type: 'object',
              properties: {
                appId: {
                  type: 'string',
                  description: 'The JianDaoYun application ID',
                },
                appKey: {
                  type: 'string',
                  description: 'The JianDaoYun application key (API key) (optional, will use JIANDAOYUN_APP_KEY from environment if not provided)',
                },
                formId: {
                  type: 'string',
                  description: 'The form ID (can be form ID or app ID)',
                },
                dataId: {
                  type: 'string',
                  description: 'The data entry ID',
                },
              },
              required: ['appId', 'formId', 'dataId'],
            },
          },
          {
            name: 'query_form_data',
            description: 'Query multiple form data entries with filtering support',
            inputSchema: {
              type: 'object',
              properties: {
                appId: {
                  type: 'string',
                  description: 'The JianDaoYun application ID',
                },
                appKey: {
                  type: 'string',
                  description: 'The JianDaoYun application key (API key) (optional, will use JIANDAOYUN_APP_KEY from environment if not provided)',
                },
                formId: {
                  type: 'string',
                  description: 'The form ID (can be form ID or app ID)',
                },
                dataId: {
                  type: 'string',
                  description: 'Last data ID for pagination',
                },
                fields: {
                  type: 'array',
                  items: { type: 'string' },
                  description: 'Fields to return (widget IDs)',
                },
                filter: {
                  type: 'object',
                  description: 'Data filter conditions',
                  properties: {
                    rel: {
                      type: 'string',
                      enum: ['and', 'or'],
                      description: 'Relation between conditions',
                    },
                    cond: {
                      type: 'array',
                      description: 'Filter conditions',
                      items: {
                        type: 'object',
                        properties: {
                          field: { type: 'string' },
                          type: { type: 'string' },
                          method: { type: 'string' },
                          value: {},
                        },
                        required: ['field', 'method'],
                      },
                    },
                  },
                  required: ['rel', 'cond'],
                },
                limit: {
                  type: 'number',
                  description: 'Number of records to return (1-100, default: 10)',
                  minimum: 1,
                  maximum: 100,
                },
              },
              required: ['appId', 'formId'],
            },
          },
          {
            name: 'update_form_data',
            description: 'Update an existing form data entry',
            inputSchema: {
              type: 'object',
              properties: {
                appId: {
                  type: 'string',
                  description: 'The JianDaoYun application ID',
                },
                appKey: {
                  type: 'string',
                  description: 'The JianDaoYun application key (API key) (optional, will use JIANDAOYUN_APP_KEY from environment if not provided)',
                },
                formId: {
                  type: 'string',
                  description: 'The form ID (can be form ID or app ID)',
                },
                dataId: {
                  type: 'string',
                  description: 'The data entry ID to update',
                },
                data: {
                  type: 'object',
                  description: 'The data to update',
                },
                transactionId: {
                  type: 'string',
                  description: 'Optional transaction ID',
                },
                isStartTrigger: {
                  type: 'boolean',
                  description: 'Whether to trigger automation',
                },
              },
              required: ['appId', 'formId', 'dataId', 'data'],
            },
          },
          {
            name: 'delete_form_data',
            description: 'Delete one or more form data entries',
            inputSchema: {
              type: 'object',
              properties: {
                appId: {
                  type: 'string',
                  description: 'The JianDaoYun application ID',
                },
                appKey: {
                  type: 'string',
                  description: 'The JianDaoYun application key (API key) (optional, will use JIANDAOYUN_APP_KEY from environment if not provided)',
                },
                formId: {
                  type: 'string',
                  description: 'The form ID (can be form ID or app ID)',
                },
                dataIds: {
                  type: ['string', 'array'],
                  description: 'Data ID(s) to delete',
                  items: { type: 'string' },
                },
                isStartTrigger: {
                  type: 'boolean',
                  description: 'Whether to trigger automation',
                },
              },
              required: ['appId', 'formId', 'dataIds'],
            },
          },
          {
            name: 'get_upload_token',
            description: 'Get file upload tokens for file/image fields',
            inputSchema: {
              type: 'object',
              properties: {
                appId: {
                  type: 'string',
                  description: 'The JianDaoYun application ID',
                },
                appKey: {
                  type: 'string',
                  description: 'The JianDaoYun application key (API key) (optional, will use JIANDAOYUN_APP_KEY from environment if not provided)',
                },
                formId: {
                  type: 'string',
                  description: 'The form ID (can be form ID or app ID)',
                },
                transactionId: {
                  type: 'string',
                  description: 'Transaction ID to bind uploads to',
                },
              },
              required: ['appId', 'formId', 'transactionId'],
            },
          },
          {
            name: 'list_apps_and_forms',
            description: 'List all available applications and their forms that the current API key can access',
            inputSchema: {
              type: 'object',
              properties: {
                appKey: {
                  type: 'string',
                  description: 'The JianDaoYun application key (API key) (optional, will use JIANDAOYUN_APP_KEY from environment if not provided)',
                },
                appId: {
                  type: 'string',
                  description: 'Optional: specific app ID to get forms for. If not provided, lists all apps.',
                },
              },
              required: [],
            },
          },
        ],
      };
Behavior2/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 of behavioral disclosure. It mentions 'query' and 'filtering support' but doesn't specify whether this is a read-only operation, what permissions are required, how pagination works (beyond the 'dataId' parameter), or error handling. For a tool with 7 parameters and no annotations, this leaves significant behavioral gaps.

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 a single, efficient sentence that directly states the tool's function without unnecessary words. It's front-loaded with the core purpose ('query multiple form data entries') and adds a useful qualifier ('with filtering support'). Every part earns its place.

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

Completeness2/5

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

Given the complexity (7 parameters, nested objects, no output schema, and no annotations), the description is inadequate. It doesn't explain the return format, error conditions, authentication requirements (implied by appId/appKey but not stated), or how filtering interacts with pagination. For a query tool with rich input schema but no output schema, more context is needed.

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 schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional parameter semantics beyond implying filtering capabilities, which are already detailed in the schema's 'filter' property. This meets the baseline for high schema coverage.

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 action ('query multiple form data entries') and resource ('form data'), making the purpose understandable. It distinguishes itself from siblings like 'get_form_data' by specifying 'multiple entries with filtering support', though it doesn't explicitly contrast with all alternatives like 'list_apps_and_forms'.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'get_form_data' (for single entries) or 'list_apps_and_forms' (for metadata). It mentions filtering support but doesn't specify scenarios where filtering is needed or when other tools might be more appropriate.

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/cheungxin/jiandaoyun-mcp-server'

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