Skip to main content
Glama

cluster_analysis

Perform KMeans clustering on numeric data from CSV, TSV, XLSX, JSON, or inline records. Returns standardized clusters with centroids, sample sizes, and silhouette scores for validation.

Instructions

cluster_analysis —— 建模组 · KMeans 聚类(工具 14,核心实现)。

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

参数: file_path (str): 本地数据文件(csv/tsv/xlsx/json) k (int): 簇数,2 <= k <= 样本数-1(非法中文报错)

口径: 仅数值列(非数值列自动排除并列出);StandardScaler z-score 标准化后 KMeans(n_clusters=k, random_state=42, n_init="auto");质心反标准化回原始单位 (标准化空间质心即簇内均值,反标准化后 = 原空间簇均值,可手算核对); 质心解读强制附簇内样本量;轮廓系数(标准化空间)+ k-1/k+1 同 seed 对照。

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kNo
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/5.0
Behavior5/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, and it does so extensively: it states that only numeric columns are used, non-numeric columns are excluded and listed, StandardScaler z-score normalization is applied, KMeans is run with fixed random_state and n_init, centroids are inverse-transformed, cluster sizes must accompany centroid interpretation, and silhouette scores are computed with k-1/k+1 comparisons. This gives the agent a clear, detailed picture of the tool's behavior.

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 well-organized into labeled sections for parameters, methodology, example, and inline data, making it scannable. Some content is meta or redundant, such as the docstring-sync note and 'tool 14' identifier, but the overall structure earns its length by providing substantive algorithm and usage detail.

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?

The description is largely complete for selecting and invoking the tool: it explains the parameters, gives a working example, and describes the preprocessing and model configuration. However, it does not explicitly describe the return format/structure of the results, and it defers some inline-data limits to an external SPEC document, which may not be accessible to the agent at invocation time.

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?

The input schema provides almost no semantic detail (0% coverage), but the description compensates fully: file_path supports csv/tsv/xlsx/json, k must satisfy 2 <= k <= sample_count-1 with error handling, and inline_data supports two concrete shapes and is mutually exclusive with file_path. Each parameter gets meaningful guidance beyond the bare type declarations.

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 identifies the tool as KMeans clustering for modeling tasks, which goes beyond the generic name 'cluster_analysis' by naming the exact algorithm. It also differentiates from sibling modeling tools like linear_regression, pca_analysis, and hypothesis_test. However, it does not phrase the purpose as a direct agent-facing action or explicitly state what kind of output the tool produces.

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 an example and states the algorithm configuration, but it never tells the agent when to choose this tool over alternatives or when not to use it. There is no explicit mention of use cases, comparisons to sibling tools, or exclusion conditions.

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