Skip to main content
Glama
cheungxin

JianDaoYun MCP Server

by cheungxin

list_apps_and_forms

Retrieve accessible applications and their forms using an API key to manage JianDaoYun form data.

Instructions

List all available applications and their forms that the current API key can access

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appKeyNoThe JianDaoYun application key (API key) (optional, will use JIANDAOYUN_APP_KEY from environment if not provided)
appIdNoOptional: specific app ID to get forms for. If not provided, lists all apps.

Implementation Reference

  • Main execution handler for the 'list_apps_and_forms' tool. Handles listing all applications or forms under a specific app using the provided appKey. Returns structured JSON with apps or forms details.
    case 'list_apps_and_forms': {
      const { appId: specificAppId } = args as { appId?: string };
      const { appId, appKey, baseUrl } = getDefaultParams(args);
      
      // 验证必需参数
      if (!appKey) {
        throw new Error('appKey is required. Please set JIANDAOYUN_APP_KEY in MCP server configuration.');
      }
      
      try {
        const targetAppId = specificAppId || appId;
        if (targetAppId) {
          // 获取特定应用的表单列表
          const jdyClient = new JianDaoYunClient({
            appId: targetAppId,
            appKey,
            baseUrl
          });
          
          try {
            const response = await axios.post(
              `${baseUrl}/api/v1/app/${targetAppId}/entry/list`,
              {},
              {
                headers: {
                  'Authorization': `Bearer ${appKey}`,
                  'Content-Type': 'application/json'
                }
              }
            );
            
            const forms = response.data || [];
            return {
              content: [
                {
                  type: 'text',
                  text: JSON.stringify({
                    appId: targetAppId,
                    forms: forms.map((form: any) => ({
                      id: form.entry_id || form._id,
                      name: form.name || '未命名表单',
                      description: form.description || '',
                      created_time: form.created_time,
                      updated_time: form.updated_time
                    })),
                    total: forms.length
                  }, null, 2),
                },
              ],
            };
          } catch (error) {
            throw new Error(`无法获取应用 "${targetAppId}" 下的表单列表: ${error instanceof Error ? error.message : '未知错误'}`);
          }
        } else {
          // 获取所有应用列表
          const apps = await getAppList(appKey);
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify({
                  apps: apps.map(app => ({
                    id: app.app_id,
                    name: app.name,
                    description: app.description || '',
                    created_time: app.created_time,
                    updated_time: app.updated_time
                  })),
                  total: apps.length,
                  message: '使用 list_apps_and_forms 工具并提供 appId 参数可以查看特定应用下的表单列表'
                }, null, 2),
              },
            ],
          };
        }
      } catch (error) {
        throw createEnhancedError(error, '获取应用和表单列表');
      }
    }
  • Input schema definition for the 'list_apps_and_forms' tool, specifying optional appKey and appId parameters.
    {
      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: [],
      },
    },
  • src/index.ts:244-508 (registration)
    Registration of all tools including 'list_apps_and_forms' in the MCP server's ListToolsRequestSchema handler.
    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: [],
            },
          },
        ],
      };
    });
  • Helper function getAppList used by the tool to fetch and cache the list of applications accessible by the appKey.
     */
    async function getAppList(appKey: string): Promise<any[]> {
      const now = Date.now();
      if (appListCache && (now - appListCacheTime) < CACHE_DURATION) {
        return appListCache;
      }
    
      try {
        const response = await axios.post(
          `${process.env.JIANDAOYUN_BASE_URL || 'https://api.jiandaoyun.com'}/api/v5/app/list`,
          {},
          {
            headers: {
              'Authorization': `Bearer ${appKey}`,
              'Content-Type': 'application/json'
            }
          }
        );
        
        // 简道云API返回格式通常是 { code: 0, data: [...] }
        const apps = response.data?.data || response.data || [];
        appListCache = Array.isArray(apps) ? apps : [];
        appListCacheTime = now;
        return appListCache;
      } catch (error) {
        console.error('Failed to fetch app list:', error);
        return [];
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool lists accessible items but does not cover key aspects like pagination, rate limits, error handling, or response format. This leaves significant gaps in understanding how the tool behaves operationally.

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 a single, clear sentence that efficiently conveys the core action. It is front-loaded and wastes no words, though it could be slightly more structured by explicitly mentioning optional parameters or output details.

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 moderate complexity (listing resources with optional filtering), no annotations, and no output schema, the description is minimally adequate. It covers the basic purpose but lacks details on behavior, output, or integration with siblings, making it incomplete for full contextual understanding.

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, so parameters are well-documented there. The description adds no additional meaning beyond implying filtering by appId, which is already covered in the schema. Thus, it meets the baseline for high schema coverage without extra value.

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 verb 'List' and the resources 'applications and their forms', making the purpose evident. However, it does not explicitly differentiate from sibling tools like 'get_form_fields' or 'query_form_data', which might also involve listing forms or data, so it lacks sibling distinction for a perfect score.

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_fields' or 'query_form_data'. It mentions access based on the API key but does not specify scenarios, prerequisites, or exclusions, leaving usage unclear.

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