get_form_data
Retrieve a specific data entry from a JianDaoYun form using app ID, form ID, and data entry ID for accurate form data management and integration.
Instructions
Get a specific data entry from a JianDaoYun form
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appId | Yes | The JianDaoYun application ID | |
| appKey | No | The JianDaoYun application key (API key) (optional, will use JIANDAOYUN_APP_KEY from environment if not provided) | |
| dataId | Yes | The data entry ID | |
| formId | Yes | The form ID (can be form ID or app ID) |
Implementation Reference
- src/index.ts:304-329 (registration)Registration of the 'get_form_data' tool, including name, description, and input schema definition.{ 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'], }, },
- src/index.ts:715-753 (handler)The handler function for the 'get_form_data' tool that validates input, resolves the form ID, creates a JianDaoYunClient instance, fetches the data, and formats the response.case 'get_form_data': { const { formId, dataId } = args as { formId: string; dataId: string }; 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 data = await jdyClient.getFormData(resolved.formId, dataId); return { content: [ { type: 'text', text: JSON.stringify({ data, formUsed: resolved.formId, appId: resolved.appId || appId }, null, 2), }, ], }; } catch (error) { throw createEnhancedError(error, '获取表单数据'); } }
- src/client.ts:208-227 (helper)Helper method in JianDaoYunClient that performs the actual API call to retrieve form data from JianDaoYun.async getFormData(formId: string, dataId: string): Promise<any> { try { const response = await this.axios.post<ApiResponse>('/v5/app/entry/data/get', { app_id: this.config.appId, entry_id: formId, data_id: dataId }); if (response.data.code !== 0) { throw new Error(`Failed to get 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; } }