Skip to main content
Glama

correlation_matrix

Computes pairwise correlations and p-values for numeric variables from data files or inline data, with Pearson, Spearman, Kendall methods and p-value adjustment for significance testing.

Instructions

correlation_matrix —— 数据探查组 · 相关矩阵(工具 4,核心实现)。

docstring = agent 使用说明书,与 statlab_mcp/docs/design/02_data_exploration_batch2.md 同步维护。

参数: file_path (str): 本地数据文件(csv/tsv/xlsx/json),仅接受本地路径 method (str, "pearson"): pearson / spearman / kendall / kendalltau(逐对取 scipy, 返回对象取 .statistic/.pvalue;pandas corr 无 p 值故不用;kendall 为 kendalltau 的官方别名 v1.1.0 起,两者结果完全相同) p_adjust (str, "fdr_bh"): none / bonferroni / fdr_bh;默认 BH-FDR 并标注; 校正单元 = 实际可计算的上三角对数(常量列对 r/p=null 不参与校正) (statsmodels.multipletests)

返回: 成功 {"status":"ok","result":{...},"summary":"..."};失败 {"status":"error",...} result: {method, n_pairs, p_adjust_method, excluded_columns, correlation, p_value, n_pairwise}(嵌套全矩阵;对角 r=1.0、p=null; 常量列对 r/p=null;n_pairwise 为成对完整样本量)

口径(红队裁决 11):每对成对完整样本;常量列 r/p=null 不参与校正; 数值列 >20 拒绝;排除非数值/全缺失列后 <2 列拒绝;p<0.001 只出现在 summary 文案。

示例: correlation_matrix("samples/clean.csv") correlation_matrix("samples/clean.csv", method="spearman", p_adjust="none") inline 数据: 本工具支持可选 inline_data 参数(v1.2.0 起):与 file_path 二选一, 支持 records 数组或 {"header": [...], "rows": [[...], ...]} 对象两种形态; 规模上限/类型域/data_source 来源标注见 statlab_mcp/docs/SPEC.md 第 12 节。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodNopearson
p_adjustNofdr_bh
file_pathNo
inline_dataNo

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv1.2.0

TDQS

A4.2/5.0
Behavior5/5

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

No annotations are present, so the description carries the full behavioral burden, and it does so extensively: scipy pairwise .statistic/.pvalue, pandas corr rejected for lacking p-values, kendall/kendalltau alias behavior, BH-FDR correction on computable upper-triangle pairs, constant-column nulls, and numeric-column error thresholds. It also discloses the success/error response envelope.

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 organized into labeled sections—params, return, 口径, examples, inline_data—and most content is operational detail earned by the absence of annotations and output schema. Meta sentences like 'docstring = agent 使用说明书' and '红队裁决 11' add maintenance context rather than invocation value, so it is not zero-waste.

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

Completeness4/5

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

It covers all essential invocation information: complete result structure, null semantics, correction unit, pairwise-complete handling, method aliases, examples, and rejection conditions. The only material deferral is inline-data scale/type rules pointed to an external SPEC document, which may not be available to the agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% and there are no enums, so the description is the only source of parameter meaning. It documents all four parameters with formats, allowed values, defaults, and side effects, including inline_data's two accepted shapes and mutual exclusivity with file_path.

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 identifies the tool as a correlation matrix in the data-exploration group and details its method options and result fields (correlation, p_value, n_pairwise), so the tool's job—computing pairwise correlation matrices—is clear. It lacks an explicit verb like 'calculates' and does not state how it differs from siblings such as plot_heatmap or hypothesis_test, so it stops just short of the highest tier.

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 intended use is implied by the tool's placement in the data-exploration group and by constraints like '数值列 >20 拒绝' and '<2 列拒绝', which tell an agent when the input is unsuitable. It never explicitly states when to choose correlation_matrix over a sibling tool and gives no alternatives or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/good-boy4069/statlab-mcp'

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