nocobase-data-analysis
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGoal
目标
Use NocoBase MCP tools to locate the right collection, query business data safely, and produce reliable summaries or grouped analysis.
使用NocoBase MCP工具定位正确的集合,安全查询业务数据,生成可靠的汇总或分组分析结果。
Prerequisite
前置条件
- NocoBase MCP must already be reachable and authenticated.
- If MCP returns authentication errors such as , stop and ask the user to refresh MCP authentication before continuing.
Auth required
- NocoBase MCP必须已可访问且已完成身份验证。
- 如果MCP返回诸如之类的身份验证错误,请停止操作,先要求用户刷新MCP身份验证后再继续。
Auth required
Default strategy
默认策略
- Inspect the data source path first.
- Prefer the data source.
main - If the target collection is not in , inspect other enabled data sources.
main - Once the collection is located, use that explicitly in every subsequent
dataSourcecall.resource_* - Prefer for counts and grouped analysis only after confirming the query parameter contract.
resource_query - Fall back to plus manual counting when query results are suspicious or need cross-checking.
resource_list
Useful references:
- for common business analysis shapes
references/analysis-patterns.md - for metric definition and scope checks
references/metric-checklist.md - for mapping business terms to collections and fields
references/entity-mapping.md
- 优先检查数据源路径。
- 优先使用数据源。
main - 如果目标集合不在中,检查其他已启用的数据源。
main - 定位到集合后,在后续所有调用中显式指定该
resource_*。dataSource - 仅在确认查询参数约定后,优先使用进行计数和分组分析。
resource_query - 当查询结果存疑或需要交叉校验时,降级使用加手动计数的方式。
resource_list
有用的参考资料:
- :常见业务分析场景模板
references/analysis-patterns.md - :指标定义和范围校验清单
references/metric-checklist.md - :业务术语与集合、字段的映射关系
references/entity-mapping.md
Data source discovery
数据源发现
- If the user explicitly names a data source, use it directly.
- Otherwise start with .
main - When the target collection is not found in , call
mainand inspect other enabled data sources one by one.data_sources:list_enabled - If multiple data sources contain the same collection name:
- default to when
mainis one of them;main - otherwise present the candidates and explain which one you are using.
- default to
- In the final answer, state which data source was used.
- 如果用户明确指定了数据源,直接使用该数据源。
- 否则默认从开始查找。
main - 当中找不到目标集合时,调用
main逐个检查其他已启用的数据源。data_sources:list_enabled - 如果多个数据源包含相同的集合名称:
- 若是其中之一,默认使用
main;main - 否则展示所有候选数据源并说明你将使用哪一个。
- 若
- 在最终答案中说明使用的是哪个数据源。
Collection discovery
集合发现
- If the user gives a collection name, verify it exists before querying.
- If the user uses business terms such as "leads", "users", "orders", or "opportunities", inspect collection metadata to map the business term to the actual collection name.
- Prefer for a fast overview.
collections:listMeta - Then use with
collections:getwhen you need exact field names, relation targets, or enum options.appends: ["fields"] - Use as a reusable heuristic for common business nouns and likely field categories.
references/entity-mapping.md
- 如果用户提供了集合名称,查询前先验证该集合是否存在。
- 如果用户使用了业务术语,例如“线索”、“用户”、“订单”或“商机”,检查集合元数据,将业务术语映射为实际的集合名称。
- 优先使用快速获取概览。
collections:listMeta - 当你需要确切的字段名称、关联目标或枚举选项时,使用携带参数的
appends: ["fields"]接口。collections:get - 可复用作为通用业务名词和对应字段类别的启发式映射规则。
references/entity-mapping.md
Query contract checks
查询约定校验
Before using , verify the request shape matches the real backend contract:
resource_query- , not
measures[].aggregationaggregate - , not
orders[].orderdirection - should usually be passed as a field path array such as
fieldor["id"]["owner", "nickname"] - Use whenever the result will be referenced in output or
aliashaving
Correct examples:
json
{
"resource": "lead",
"dataSource": "main",
"measures": [
{ "aggregation": "count", "field": ["id"], "alias": "lead_count" }
]
}json
{
"resource": "lead",
"dataSource": "main",
"dimensions": [
{ "field": ["status"], "alias": "status" }
],
"measures": [
{ "aggregation": "count", "field": ["id"], "alias": "lead_count" }
],
"orders": [
{ "field": ["status"], "alias": "status", "order": "asc" }
]
}使用前,验证请求格式是否符合实际后端约定:
resource_query- 使用而非
measures[].aggregationaggregate - 使用而非
orders[].orderdirection - 通常应作为字段路径数组传递,例如
field或["id"]["owner", "nickname"] - 当结果会在输出或中被引用时,务必使用
havingalias
正确示例:
json
{
"resource": "lead",
"dataSource": "main",
"measures": [
{ "aggregation": "count", "field": ["id"], "alias": "lead_count" }
]
}json
{
"resource": "lead",
"dataSource": "main",
"dimensions": [
{ "field": ["status"], "alias": "status" }
],
"measures": [
{ "aggregation": "count", "field": ["id"], "alias": "lead_count" }
],
"orders": [
{ "field": ["status"], "alias": "status", "order": "asc" }
]
}Recommended workflow
推荐工作流
1. Confirm reachability
1. 确认可访问性
- Use .
auth:check - If authentication fails, stop.
- 使用接口。
auth:check - 如果身份验证失败,停止操作。
2. Find the collection
2. 查找集合
- First inspect .
main - If not found, inspect other enabled data sources.
- Read fields before querying if field names or relations are uncertain.
- 首先检查数据源。
main - 如未找到,检查其他已启用的数据源。
- 如果不确定字段名称或关联关系,查询前先读取字段信息。
3. Start with simple counts
3. 从简单计数开始
- Use with a single
resource_querymeasure.count(id) - Keep the first query minimal so you can validate the result shape quickly.
- 使用仅携带单个度量的
count(id)请求。resource_query - 保持首次查询尽可能简洁,以便你可以快速验证结果格式。
4. Add grouped analysis
4. 增加分组分析
Common grouped views:
- by status
- by owner
- by source
- by department
- by created date or month
For relation labels, use field paths such as:
["owner", "nickname"]["mainDepartment", "title"]
常见分组视图:
- 按状态
- 按负责人
- 按来源
- 按部门
- 按创建日期或月份
对于关联对象标签,使用字段路径,例如:
["owner", "nickname"]["mainDepartment", "title"]
5. Cross-check when needed
5. 必要时交叉校验
Re-check with when:
resource_list- the grouped rows look duplicated unexpectedly;
- the numeric result looks like record IDs instead of counts;
- totals do not match between summary and grouped output;
- the collection may be affected by ACL scope or hidden filters.
When cross-checking:
- fetch enough rows to cover the visible dataset or use pagination;
- count and group manually from the returned records;
- compare the manual result with .
resource_query
出现以下情况时,使用重新校验:
resource_list- 分组行意外出现重复;
- 数值结果看起来像记录ID而非计数;
- 汇总结果和分组输出的总计不匹配;
- 集合可能受ACL范围或隐藏筛选器影响。
交叉校验时:
- 拉取足够多的行覆盖可见数据集,或使用分页;
- 基于返回的记录手动计数和分组;
- 对比手动计算结果与的结果。
resource_query
6. Present the result
6. 展示结果
Report:
- the collection used;
- the data source used;
- the total count;
- the key grouped breakdowns;
- any caveat such as ACL scope, null values, or fallback to manual verification.
报告内容需包含:
- 使用的集合;
- 使用的数据源;
- 总计数;
- 核心分组明细;
- 任何注意事项,例如ACL范围、空值、或降级使用手动验证的情况。
Analysis entry points
分析入口分类
Classify the user request before querying:
- for current totals and main distributions
overview - for grouped counts by status, owner, source, team, or department
distribution - for stage-based business progression
funnel - for date or month-based change over time
trend - for top owners, sources, accounts, or products
ranking - for missing values, null-heavy fields, suspicious statuses, or orphaned relations
quality-check
Use for the recommended query shapes for each pattern.
references/analysis-patterns.md查询前先对用户请求进行分类:
- :当前总计和主要分布情况
overview - :按状态、负责人、来源、团队或部门的分组计数
distribution - :基于阶段的业务流程转化
funnel - :按日期或月份的随时间变化趋势
trend - :排名靠前的负责人、来源、客户或产品
ranking - :缺失值、空值占比高的字段、可疑状态、或孤立关联关系
quality-check
每种模式的推荐查询格式可参考。
references/analysis-patterns.mdMetric definition checks
指标定义校验
Before returning an answer, verify the metric scope:
- what time range is included
- which time field drives the range
- whether the metric is total count, distinct count, sum, or average
- whether archived, inactive, null, or other terminal states should be included
- whether grouped totals reconcile with the grand total
Use when the user request is ambiguous or the metric may be interpreted in more than one way.
references/metric-checklist.md返回答案前,校验指标范围:
- 包含的时间范围
- 驱动时间范围的时间字段
- 指标是总计数、去重计数、求和还是平均值
- 是否应该包含已归档、非活跃、空值或其他终止状态的数据
- 分组总计是否与总计数一致
当用户请求不明确或指标存在多种解读方式时,参考。
references/metric-checklist.mdCommon pitfalls
常见陷阱
- Do not assume the collection is in ; check
mainfirst, then search other enabled data sources.main - Do not omit after the collection has been located.
dataSource - Do not use in query measures; the backend expects
aggregate.aggregation - Do not use in query orders; the backend expects
direction.order - Do not assume suspicious aggregate output is correct.
- If a "count" result looks like ,
36,54, or another plausible record ID, verify whether aggregation was actually applied.80 - Relation label grouping requires the real relation path and target field, not guessed labels.
- 不要假设集合一定在中;先检查
main,再搜索其他已启用的数据源。main - 定位到集合后不要遗漏参数。
dataSource - 不要在查询度量中使用;后端期望的参数是
aggregate。aggregation - 不要在查询排序中使用;后端期望的参数是
direction。order - 不要默认可疑的聚合输出是正确的。
- 如果“计数”结果看起来像、
36、54或其他合理的记录ID,验证是否实际应用了聚合逻辑。80 - 关联标签分组需要使用真实的关联路径和目标字段,而非猜测的标签。
Verification checklist
校验清单
- MCP is authenticated.
- The collection exists in the chosen data source.
- The fields used in ,
dimensions,measures, andordersactually exist.filter - uses
resource_queryandaggregation.order - Summary totals match grouped totals, or any mismatch is explained.
- The final answer states the data source and any verification fallback used.
- MCP已完成身份验证。
- 集合在选择的数据源中存在。
- 、
dimensions、measures和orders中使用的字段真实存在。filter - 使用了
resource_query和aggregation参数。order - 汇总总计与分组总计匹配,或对不匹配的情况做出了解释。
- 最终答案说明了使用的数据源和所有降级验证的方式。