CSV分析工具

一个基于Python的MCP服务器,用于探索和分析CSV文件,提供列表、预览、过滤和描述数据集的功能。

  • by Shore99
  • Python
  • 混合部署
  • 更新于
在 GitHub 查看 Shore99/MCP_Test

使用说明

CSV分析员——MCP服务器

一个用Python编写的小型MCP(模型上下文协议)服务器,用于浏览和分析CSV文件。
通过工具列出,查看,过滤和描述数据集(@mcp.tool及时互动。

要求

  • python 3.10+

安装

克隆仓库:

git clone https://github.com/Shore99/MCP_Test.git

安装依赖关系:

pip install -r requirements.txt

在“日期”文件夹中插入要分析的 CSV

MCP 服务器启动(MCP CLI)

打开两个不同的终端,确保您在路径src。

在第一个(MCP Inspector)中运行:

mcp dev main.py  

而在第二(服务器启动):

mcp run src/main.py --transport=streamable-http

项目结构

.
├── src/
│   └── main.py              # Logica MCP server (tools, resources, prompts)
├── data                     # Cartella per i CSV locali (non versionati)
├── requirements.txt         # Dipendenze (mcp[cli], uvicorn)
├── .gitignore
├── README.md

MCP工具(Tools MCP)

Tool	                                Descrizione
list_csvs()	                        #Elenca i file CSV nella cartella data/
preview_csv(filename, n)	        #Mostra le prime n righe del file
describe_csv(filename)	                #Calcola statistiche di base sulle colonne
filter_equals(filename, column, value)	#Filtra le righe dove column == value

例如 mcp.json

{
  "name": "CSV Analyst",
  "version": "0.1.0",
  "transport": {
    "type": "http",
    "url": "http://127.0.0.1:8000/mcp"
  },
  "metadata": {
    "description": "Simple MCP server to inspect CSV files under ./data"
  }
}