本地AI数据处理工具

MCP Server是一个轻量级的Python工具,通过Model Context Protocol(MCP)服务器实现AI助手(如Claude)与本地数据文件(如CSV和Parquet)的交互,支持自然语言查询和数据处理。

  • by Hassenamri005
  • Python
  • 本地部署
  • 4 星标
  • 更新于
在 GitHub 查看 Hassenamri005/mcp-server-example

使用说明

🧠 MCP服务器:使用Python的本地AI工具

该项目使用Python建立了一个轻量级的模型上下文协议(MCP)服务器,使像Claude这样的人工智能助手能够与CSV和Parquet等本地数据文件进行交互。通过与Claude for Desktop集成,您可以执行汇总数据集或通过自然语言查询检索特定信息等任务

🚀 特性

本地MCP服务器(mix_server):促进克劳德和您当地工具之间的沟通。 CSV和拼花游戏阅读器:用于加载和处理数据分析中常用的表格数据格式的工具。 模块化结构:干净的代码库,设计用于使用附加工具轻松扩展。 无缝集成Claude:直接与Claude for Desktop连接,允许与您的数据进行自然语言交互。

🛠️ 安装

1.克隆仓库

git clone https://github.com/yourusername/mcp-server.git
cd mcp-server
``


### 2. Set Up the Environment Using `uv

[uv](https://github.com/astral-sh/uv) is a fast Python package and project manager written in Rut It serves as a drop-in replacement for tools like `pip`, `pip-tools`, and `virtualenv`, offering significant speed improvements and a unified interfae.

#### Install `uv

You can install `uv` using one of the following methos:

- **Using `curl` (macOS and Linux):**

```bash
  curl -LsSf https://astral.sh/uv/install.sh | sh
  ``


- **Using `pip`:**

```bash
  pip install uv
  ``


- **Using `pipx`:**

```bash
  pipx install uv
  ``


For more installation options and details, refer to the [official uv documentation](https://docs.astral.sh/uv).

#### Create a Virtual Environment and Install Dependencie


```bash
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv pip install mcp[cli] pandas pyarrow
``


This will create a virtual environment and install the necessary dependencies using `u`.

## 📁 Project Structue


```bash
mcp-server/
├── tools/
│   ├── csv_reader.py
│   └── parquet_reader.py
├── mix_server.py
├── README.md
└── requirements.txt
``

- `tools/`: Contains individual tool scripts for data processng.
- `mix_server.py`: Initializes and runs the MCP server, registering available tols.

## ⚙️ Configuration for Claude Desktp

To integrate with Claude for Desktop, add the following configuration to your Claude settigs:


```json
{
  "mcpServers": {
    "mix_server": {
      "command": "/absolute/path/to/.venv/bin/python",
      "args": ["/absolute/path/to/mix_server.py"]
    }
  }
}
``


Ensure that the paths to your Python interpreter and `mix_server.py` are corrct.

## 🧪 Usge

Once set up, you can interact with your data through Claude using natural language prompts. For exaple:

- "Summarize the contents of `data.cv`."
- "How many rows and columns are in `dataset.parqut`?

Claude will utilize the registered tools to process your request and provide the desired informaion.

## 📚 Refereces

This project is based on the tutorial: [Building a Basic MCP Server with Python](https://medium.com/data-engineering-with-dremio/building-a-basic-mcp-server-with-python-4c34c4101ed).

## 📝 Liense

This project is licensed under the [MIT License](LIENSE).