Skip to main content
Glama

DataMineAna

Mathematical modeling MCP toolkit -- provides data preprocessing, data analysis, mathematical modeling, and data visualization capabilities for LLMs/Agents.

Architecture

+-----------------------------------------------+
|            Modeling Skill (上层)               |
+-----------------------------------------------+
|         MCP Client (中层)                      |
|    - 与大模型交互                              |
|    - 智能文档传递(先常用,再全量)            |
|    - 工具调用解析与转发                        |
+-----------------------------------------------+
|         MCP Server (底层)                      |
|    - 工具注册与分发(37 个工具)               |
|    - 数据预处理(38 个方法)                   |
|    - 数据分析(29 个方法)                     |
|    - 数学建模(47 个方法)                     |
|    - 数据可视化(10 种图表)                   |
|    - 高级扩展(动态方法创建)                  |
|    - 数据档案追踪(核心)                      |
|    - 缓存管理                                  |
+-----------------------------------------------+
|         UI Module (可选)                       |
|    - 交互式数据建模工作台                      |
|    - 逐步向导:加载->预处理->分析->可视化->建模->报告 |
|    - Gradio Web UI                             |
|    - 基于 MCP Server(非直接调用)             |
+-----------------------------------------------+

Related MCP server: eda-mcp

Core Features

Plugin-based Method Architecture

Each method class inherits BaseMethod and is loaded and executed via MethodLoader. Method classes are not exposed externally; they are accessed only through the Interface.

module/
  methods/           # 方法类(隐藏)
    cleaning.py      # 相关方法分组
    transformation.py
  loader.py          # MethodLoader 子类(注册所有方法)
  interface.py       # 公开接口(集成 tracker)

Data Profile Tracking System (Core)

  • Automatically records input/output information before and after each function call

  • Maintains a global data profile (shape, columns, types, missing values, statistics, column details)

  • Tracks the entire process from data loading to the end of modeling

  • get_pipeline_report generates a complete record of call steps (for writing papers)

Smart Documentation Delivery

  1. Initial delivery: MCP_USAGE.md + COMMON_API.md (20 common tools)

  2. On-demand delivery: FULL_API.md (37 tools + 114 methods)

return_mode Controls Return Content

Each tool supports the return_mode parameter to control the returned content:

  • summary (default), full, data, head, tail, sample, path

Dynamic Method Extension

  • Advanced extension: pass a Python code string to create_method to dynamically create new methods

  • External extension: place method class files in src/advanced/methods/ or cache/advanced/, and they are loaded automatically

  • UI customization: UI users can also write custom methods in the interface

Data Visualization

  • 10 chart types: distribution plots, box plots, scatter plots, heatmaps, confusion matrices, ROC curves, etc.

  • Supports before/after comparison (before vs. after processing)

  • Images are automatically saved to cache/plotting/

Directory Structure

DataMineAna/
  src/
    common/              # 公共函数库
      base_method.py     # 方法基类(ParameterDef 支持 UI 自动表单)
      method_loader.py   # 方法加载器
      types.py           # 类型定义
      validators.py      # 参数校验
      json_utils.py      # JSON 工具
    tracker/             # 数据档案与追踪系统(核心)
      data_profile.py    # 数据档案
      profile_manager.py # 档案管理器
      call_tracker.py    # 调用追踪器
    cache_manager/       # 缓存管理
    preprocessing/       # 数据预处理(38 个方法)
    analysis/            # 数据分析(29 个方法)
    modeling/            # 数学建模(47 个方法)
    plotting/            # 数据可视化(10 种图表)
      plotter.py         # 核心绘图引擎
      interface.py       # 可视化接口
    advanced/            # 高级扩展
      loader.py          # 动态方法加载器
      template.py        # 扩展模板
      methods/           # 内置扩展方法
    mcp_server/          # MCP Server(底层接口)
    mcp_client/          # MCP Client(中层)
    ui/                  # 交互式 UI 模块
      app.py             # Gradio 主应用
      state.py           # 会话状态(基于 MCP Server)
      pages/
        page_load.py     # 1. 数据加载
        page_preprocess.py # 2. 数据预处理
        page_analysis.py # 3. 数据分析
        page_plot.py     # 4. 数据可视化
        page_model.py    # 5. 模型构建
        page_report.py   # 6. 流水线报告
        components.py    # 共享 UI 组件
  cache/                 # 临时文件目录
    preprocessing/       # 预处理临时文件
    analysis/            # 分析临时文件
    modeling/            # 建模临时文件
    plotting/            # 图表临时文件
    advanced/            # 动态方法文件
    tracker/             # 追踪临时文件
    ui/                  # UI 临时文件
  docs/                  # 文档
  test.py               # 集成测试(20 个测试)
  run_ui.py             # UI 启动入口

Quick Start

MCP Server (for Agent Use)

from src.mcp_server import MCPServer

server = MCPServer()

# 加载数据
r = server.call_tool("load_data", path="data.csv")

# 数据清洗
r = server.call_tool("clean_data", dataset_id="ds_xxx", missing_strategy="mean")

# 数据可视化
r = server.call_tool("plot_distribution", dataset_id="ds_xxx")
r = server.call_tool("plot_box", dataset_id="ds_xxx")

# 建模
r = server.call_tool("regression", dataset_id="ds_xxx", target_column="y")

# 获取完整报告
r = server.call_tool("get_pipeline_report")

Interactive UI (for Human Use)

python run_ui.py              # 默认端口 7860
python run_ui.py --port 8080  # 自定义端口
python run_ui.py --no-open    # 不自动打开浏览器

UI workflow:

  1. Load Data - Upload a data file

  2. Preprocess - Clean, transform, reduce dimensions, split

  3. Analyze - Descriptive statistics, correlation, distribution, hypothesis testing

  4. Visualize - Distribution plots, box plots, scatter plots, heatmaps, before/after comparison

  5. Model - Regression/classification/clustering/cross-validation/grid search

  6. Report - Generate a complete pipeline report

Method Count Statistics

Module

Methods

Tools

Data Preprocessing

38

9

Data Analysis

29

6

Mathematical Modeling

47

8

Data Visualization

10

6

Advanced Extension

Dynamic

2

System Tools

-

6

Total

124+

37

Extension Methods

Method 1: Inherit BaseMethod

from src.common.base_method import BaseMethod, MethodResult, ParameterDef

class MyMethod(BaseMethod):
    @property
    def name(self): return "my_method"
    @property
    def description(self): return "My custom method"
    @property
    def category(self): return "custom"
    @property
    def parameters(self):
        return [
            ParameterDef(name="threshold", type="float", default=0.5, description="Threshold value"),
        ]

    def execute(self, df, **kwargs):
        threshold = kwargs.get("threshold", 0.5)
        # your logic here
        return MethodResult(df=df, success=True, message="done")

Method 2: Dynamic Creation (via MCP)

server.call_tool("create_method", code='''
class MyMethod(BaseMethod):
    @property
    def name(self): return "my_method"
    @property
    def description(self): return "My custom method"
    def execute(self, df, **kwargs):
        return MethodResult(df=df, success=True, message="done")
''', module="preprocessing")

Method 3: Add to the Advanced Extension Directory

Place method files in src/advanced/methods/ (persistent) or cache/advanced/ (temporary), and they are loaded automatically.

Dependencies

  • Python >= 3.10

  • pandas >= 2.0

  • numpy >= 1.24

  • scikit-learn >= 1.3

  • scipy >= 1.11

  • matplotlib >= 3.7

  • seaborn >= 0.12

  • gradio >= 4.0 (UI module)

License

MIT License

Related MCP Connectors

Related MCP Servers

  • F
    license
    B
    quality
    D
    maintenance
    An MCP server that provides data visualization and machine learning tools, featuring automated intent-based pipeline routing for data cleaning and model training. It enables LLMs to process CSV or JSON data to generate visual charts, perform regressions, or execute clustering analysis.
    16
    -
  • A
    license
    A
    quality
    D
    maintenance
    Enables exploratory data analysis through an MCP server, allowing AI assistants to load datasets, compute summary statistics, generate diagnostic plots, perform correlation analysis, and produce full markdown reports.
    6
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    An MCP server for dataset exploration and analysis, enabling LLM clients to perform summary, correlation, distribution, missing value analysis, data cleaning, and statistical tests directly on CSV files.
    3
    -