Skip to main content

用数据库的方式提供读取、分析 Excel 文件的 MCP 服务

Project description

项目

  • python 3.12.12
  • fastmcp 2.14.2
  • pandas、polars
  • 单元测试用 unittest
  • 测试用例在 tests 文件夹下
  • 目的是为了解决,读取Excel 会返回整个表信息,导致token 爆炸的问题,而用数据库的形式,可以让LLM 逐步进行数据分析,避免token 爆炸的问题。

技术方案

  • 是用 uv 管理和打包,.venv 为虚拟环境目录
  • 用DB 的方式提供读取、分析 Excel
  • Sheet = Dbname
  • 表头就是字段
  • 行号 = id
  • 提供 pandas 和 polars 两种数据处理方式

文件夹

  • src
    • tools 每个工具单独一个文件夹

tools

  • get_sheet_list 获取所有sheet 列表、名称
  • select_count_sheet_rows 获取 sheet 的行数
  • select_sheet_rows_by_id 获取 sheet 的某一行数据
  • select_sheet_rows_by_title_where 根据多个表头的条件(可以完全匹配、模糊匹配、正则匹配、大于小于、区间、包含、不包含) 获取 sheet 的某行数据
  • group_by_sheet_title_get_count_and_values 对某个表头进行分组,统计内容、行数
  • search_row_in_sheet_by_keyword 在某个sheet 中搜索某个关键字
  • query_by_sql 使用 SQL 语句查询 sheet 数据,支持完整的 SQL 语法(SELECT、WHERE、GROUP BY、ORDER BY、HAVING、LIMIT 等),使用 polars SQLContext 实现

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uvx_excel_read_dbmod-0.2.1.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uvx_excel_read_dbmod-0.2.1-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file uvx_excel_read_dbmod-0.2.1.tar.gz.

File metadata

  • Download URL: uvx_excel_read_dbmod-0.2.1.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for uvx_excel_read_dbmod-0.2.1.tar.gz
Algorithm Hash digest
SHA256 69ca467cf73c69dc4404c600cab08b02367eedbfae15f2954c8e3eb0c1bf60ea
MD5 4044d23140783aef6f7540864ae02d61
BLAKE2b-256 44cbbe21354e95b68cff33f854192a874bacde55344545d0a601138d7a3ea8b6

See more details on using hashes here.

File details

Details for the file uvx_excel_read_dbmod-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for uvx_excel_read_dbmod-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 91377adb19779ed13040654c473116e0e09dee90a01043b0518d001c3a9d7a8d
MD5 908a11b6d924283bb1f2338f2f7292c9
BLAKE2b-256 6f76aa47601f6f3da160f9419a06cab7ce0e6a49869cee68c87d23d7a77e2d2f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page