Skip to main content
Glama

trend_analysis

Detect and quantify trends in time-series data with Mann-Kendall and Theil-Sen methods. Returns trend direction, strength, and significance (tau, p, slope) from CSV, JSON, Excel, or inline data.

Instructions

trend_analysis —— 时序组 · 趋势分析(工具 19,简化实现)。

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

参数: file_path (str): 本地数据文件(csv/tsv/xlsx/json) date_col / value_col (str): 日期列与数值列 method (str, "mann_kendall"): mann_kendall / theil_sen

口径: Mann-Kendall:scipy.stats.kendalltau(y, 时间序号) 的 tau 与 p(MK 检验的 tau 统计量 + 正态近似双侧 p,scipy 官方实现,输出注明该口径); Theil-Sen 斜率:点对斜率中位数(n<=2000 全枚举;n>2000 固定 seed 抽样 50000 对并注明);两种方法都输出 tau/p/slope,method 决定 slope 的计算主口径 (theil_sen 时 slope 为点对中位数;mann_kendall 时 slope 同样用 Theil-Sen 斜率, tau 为主统计量)。 含季节成分时输出"趋势结论需谨慎"警示(设计文档:不校正)。

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodNomann_kendall
date_colNo
file_pathNo
value_colNo
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
Behavior4/5

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

With no annotations, the description carries full burden and compensates well: it discloses the exact statistical formulas (kendalltau, normal approximation p), the Theil-Sen pairwise slope median, sampling behavior for n>2000 with fixed seed, and the seasonality warning. It stops short of describing exact return structure or error handling, but the core behavioral traits are covered.

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 clearly structured into sections (parameters, methodology, example, inline data) and front-loads the purpose. Some meta-commentary (docstring sync, tool number) is extraneous, but the density of useful information justifies the length.

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?

For a tool with no annotations, no output schema, and five undocumented parameters, the description covers inputs, methods, output values, and cautions. It references external docs for inline data limits, which is a minor completeness gap if those docs are not accessible to the agent, but overall it is sufficient for correct invocation.

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 the description compensates thoroughly: it explains file_path supported formats, date_col/value_col roles, method options with defaults, and inline_data shapes plus exclusivity with file_path. It also clarifies the statistical meaning of method choices, adding value far beyond the bare schema.

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 time-series trend analysis with specific statistical methods (Mann-Kendall and Theil-Sen) and output values (tau/p/slope). It differentiates from siblings by its focus on trend statistics rather than forecasting or decomposition, though it does not explicitly name alternative tools.

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 description gives implementation details for method selection and clarifies the mutually exclusive file_path vs inline_data inputs, but it does not explicitly state when to use trend_analysis over sibling tools like seasonal_decompose or time_series_forecast. The 'seasonal component caution' hint implies one alternative but does not name it.

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