xby-csv2json
No description
- Stars
- 0
- Language
- TypeScript
- Created
- Aug 28, 2026
- Updated
- Aug 28, 2026
Introduction
xby-csv2json
DeepSeek Harness (DSH) 的插件:CSV转JSON转换器
一个基于FastMCP的CSV到JSON转换MCP服务器,提供高效的CSV数据转换服务。
功能
- set_xby_apikey — 在聊天中设置 API 密钥(自动持久化,重启有效)
- get_csv_info — 获取 CSV 文件的基本信息,用于辅助转换操作。
Args: file_path: CSV 文件路径,必须是有效的文件路径
Returns: 包含 CSV 文件信息的字典,结构为: { "success": bool, # 操作是否成功 "file_info": Dict[str, Any], # 文件详细信息 "message": str # 操作结果消息 }
文件信息包含以下字段:
- file_size: 文件大小(字节)
- row_count: 行数(估算值)
- column_count: 列数
- columns: 列名列表
- sample_data: 示例数据(前几行)
- file_encoding: 文件编码
- detected_delimiter: 检测到的分隔符
Raises: FileNotFoundError: 当文件路径不存在时 ValueError: 当文件格式错误或读取失败时 Exception: 其他未知错误
- convert_csv_file — 将 CSV 文件转换为 JSON 文件。
Args: file_path: CSV 文件路径,必须是有效的文件路径 output_file_path: 输出 JSON 文件路径(可选,默认为 CSV 文件同目录下同名 .json 文件) delimiter: CSV 分隔符,默认为逗号(,),可以是制表符( )、分号(;)等 encoding: 文件编码,默认为 utf-8,支持 gbk、gb2312 等常见编码 skip_rows: 跳过的行数,默认为 0,用于跳过文件开头的注释或空行 header: 是否包含表头,默认为 True,如果为 False 则使用列索引作为键名 orient: JSON 输出格式,默认为 "records",可选值: - "records": 每行作为一个字典对象的列表 - "values": 仅包含值的二维数组 - "split": 分开存储列名和数据的格式 indent: JSON 缩进,默认为 None(紧凑格式),可设置为 2 或 4 等值
Returns: 包含转换结果的字典,结构为: { "success": bool, # 转换是否成功 "json_file_path": str, # 生成的 JSON 文件路径 "message": str # 操作结果消息 }
Raises: FileNotFoundError: 当文件路径不存在时 ValueError: 当文件格式错误或转换失败时 Exception: 其他未知错误
- convert_csv_string — 将 CSV 格式的字符串转换为 JSON 格式。
Args: csv_content: CSV 格式的字符串内容,必须包含有效的 CSV 数据 delimiter: CSV 分隔符,默认为逗号(,),可以是制表符( )、分号(;)等 skip_rows: 跳过的行数,默认为 0,用于跳过字符串开头的注释或空行 header: 是否包含表头,默认为 True,如果为 False 则使用列索引作为键名 orient: JSON 输出格式,默认为 "records",可选值: - "records": 每行作为一个字典对象的列表 - "values": 仅包含值的二维数组 - "index": 包含索引的字典 - "table": 包含 schema 和数据的完整表格格式 - "split": 分开存储列名和数据的格式 indent: JSON 缩进,默认为 None(紧凑格式),可设置为 2 或 4 等值
Returns: 包含转换结果的字典,结构为: { "success": bool, # 转换是否成功 "json": Any, # 转换后的 JSON 数据 "message": str # 操作结果消息 }
Raises: ValueError: 当字符串格式错误或转换失败时 Exception: 其他未知错误
安装
方式一:从 GitHub 直接安装(推荐)
# 格式: dsh plugin --profile <profile> add github:<owner>/<repo>
dsh plugin --profile web add github:xby_skill/xby-csv2json
方式二:从本地目录安装(开发模式)
# 仅用于本地开发调试
dsh plugin --profile web add /absolute/path/to/xby-csv2json
方式三:通过 cordis.patch.yml 开发调试
dsh web --profile web --patch /absolute/path/to/dsh-ocr-plugin/cordis.patch.yml
配置
获取 API 密钥
前往 小笨羊官网 注册并获取 API 密钥。