bibtex-file-mcp


Namebibtex-file-mcp JSON
Version 1.1.0 PyPI version JSON
download
home_pageNone
SummaryBibTeX MCP Server for manipulating BibTeX entries
upload_time2025-09-11 02:24:29
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords bibtex mcp bibliography reference-management citation latex
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # BibTeX MCP Server

[![PyPI version](https://badge.fury.io/py/bibtex-file-mcp.svg)](https://badge.fury.io/py/bibtex-file-mcp)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-green.svg)](https://modelcontextprotocol.io/)

🚀 **一个高效的 BibTeX 文件操作 MCP 服务器**

基于 [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) 构建,让 AI 助手(如 Cursor)能够智能地读取、查询和管理 BibTeX 文献数据库。

## ✨ 特色亮点

- **📚 BibTeX 支持** - 完整的 `.bib` 文件解析和处理
- **🤖 AI 友好** - 专为 LLM 设计的简洁 API
- **⚡ 即开即用** - 使用 `uvx` 一键启动,无需复杂配置
- **🔧 Cursor 集成** - 完美集成到 Cursor 编辑器的 MCP 系统
- **🎯 轻量高效** - 专注核心功能,性能卓越

## 功能特性

### 🎯 核心功能
- **读取文件** - 默认返回所有key,可选显示前5条详细信息
- **查询条目** - 根据key获取单条entry的详细信息  
- **写入文件** - 根据key列表筛选并写入新文件

## 使用uvx运行

### 安装和运行
```bash
# 从 PyPI 直接运行(推荐)
uvx bibtex-file-mcp

# 或者使用服务器名称
uvx --from bibtex-file-mcp bibtex-mcp-server

# 从本地项目运行
uvx --from . bibtex-mcp-server

# 指定 Python 版本
uvx --python 3.10+ --from bibtex-file-mcp bibtex-file-mcp
```

### 依赖配置
项目已配置 `pyproject.toml`,uvx会自动处理依赖安装。

## 🎯 Cursor 中的配置

### 方式一:从 PyPI 安装(推荐)

发布到 PyPI 后,在 Cursor 的 MCP 服务器设置中添加以下 JSON 配置:

```json
{
  "mcpServers": {
    "bibtex-mcp": {
      "command": "uvx",
      "args": ["bibtex-file-mcp"]
    }
  }
}
```

### 方式二:从本地项目运行

如果你想从本地项目运行(开发或测试),使用以下配置:

```json
{
  "mcpServers": {
    "bibtex-mcp": {
      "command": "uvx",
      "args": [
        "--from",
        "/path/to/your/bibtex_mcp",
        "bibtex-mcp-server"
      ],
      "env": {
        "PYTHONPATH": "/path/to/your/bibtex_mcp"
      }
    }
  }
}
```

### 🚀 配置完成后的使用

配置完成后,你可以在 Cursor 中直接使用 BibTeX 工具:

```
请帮我读取 references.bib 文件并显示所有条目的 key
```

```
从 library.bib 中找到 key 为 "smith2024" 的条目详细信息
```

```
从 all_papers.bib 中选择这些条目:["paper1", "paper2", "paper3"] 并保存到 selected.bib
```

## 可用工具

### 1. `read_bibtex_file(filepath, show_details=False)`
读取BibTeX文件

```python
# 获取所有key(默认)
read_bibtex_file("references.bib")

# 显示前5条详细信息
read_bibtex_file("references.bib", show_details=True)
```

### 2. `get_bibtex_entry(filepath, key)`
根据key获取单条条目详细信息

```python
get_bibtex_entry("references.bib", "smith2024")
```

### 3. `write_bibtex_entries(source_filepath, target_filepath, keys)`
根据key列表写入选定条目到新文件

```python
write_bibtex_entries(
    source_filepath="all_refs.bib",
    target_filepath="selected_refs.bib", 
    keys=["smith2024", "doe2023", "jones2022"]
)
```

## 典型工作流程

1. **浏览文献库**:
   ```python
   # 查看所有可用的key
   read_bibtex_file("my_library.bib")
   ```

2. **查看具体条目**:
   ```python
   # 查看感兴趣的条目详情
   get_bibtex_entry("my_library.bib", "interesting_paper_2024")
   ```

3. **创建子集**:
   ```python
   # 筛选相关论文到新文件
   write_bibtex_entries(
       "my_library.bib", 
       "project_refs.bib",
       ["paper1_2024", "paper2_2023", "paper3_2024"]
   )
   ```

## 项目结构

```
bibtex_mcp/
├── bibtex_file_mcp.py    # 主程序
├── pyproject.toml        # uvx配置文件
├── requirements.txt      # 依赖列表
└── README.md            # 使用说明
```

## 特点

- **轻量高效** - 只保留核心功能,没有冗余
- **假设正确** - 假设所有BibTeX格式都是正确的
- **简单解析** - 使用简单正则表达式解析
- **uvx友好** - 支持uvx一键运行和配置

## 系统要求

- Python 3.10+
- 依赖包:
  - `mcp>=0.1.0`
  - `fastmcp>=0.1.0` 
  - `pydantic>=2.0.0`

## 使用uvx的优势

- 无需手动管理虚拟环境
- 自动处理依赖安装
- 一次性运行,无残留
- 支持不同Python版本

## 📦 安装和获取

### 从 PyPI 安装(推荐)

```bash
# 直接运行,无需预安装
uvx bibtex-file-mcp

# 或者安装到系统
pip install bibtex-file-mcp
bibtex-file-mcp
```

### 从源码安装

```bash
# 克隆仓库
git clone https://github.com/Qing25/bibtex-file-mcp.git
cd bibtex-file-mcp

# 从本地运行
uvx --from . bibtex-mcp-server

# 或者本地安装
pip install -e .
```

## 🔧 开发和贡献

```bash
# 克隆项目
git clone https://github.com/Qing25/bibtex-file-mcp.git
cd bibtex-file-mcp

# 设置开发环境
uv venv
source .venv/bin/activate  # Linux/Mac
# 或 .venv\Scripts\activate  # Windows

# 安装依赖
uv pip install -e .

# 运行测试
python test_tools.py
```

## 📄 许可证

MIT License - 详见 [LICENSE](LICENSE) 文件

## 🤝 贡献

欢迎提交 Issue 和 Pull Request!

- GitHub: [https://github.com/Qing25/bibtex-file-mcp](https://github.com/Qing25/bibtex-file-mcp)
- Issues: [https://github.com/Qing25/bibtex-file-mcp/issues](https://github.com/Qing25/bibtex-file-mcp/issues)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "bibtex-file-mcp",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "Qing <aqsz2@outlook.com>",
    "keywords": "bibtex, mcp, bibliography, reference-management, citation, latex",
    "author": null,
    "author_email": "Qing <aqsz2526@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/79/bd/67cf642feefc5f3a8688b6a2bf583226f202834debe0b7fa9d0fe1391c9b/bibtex_file_mcp-1.1.0.tar.gz",
    "platform": null,
    "description": "# BibTeX MCP Server\n\n[![PyPI version](https://badge.fury.io/py/bibtex-file-mcp.svg)](https://badge.fury.io/py/bibtex-file-mcp)\n[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-green.svg)](https://modelcontextprotocol.io/)\n\n\ud83d\ude80 **\u4e00\u4e2a\u9ad8\u6548\u7684 BibTeX \u6587\u4ef6\u64cd\u4f5c MCP \u670d\u52a1\u5668**\n\n\u57fa\u4e8e [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) \u6784\u5efa\uff0c\u8ba9 AI \u52a9\u624b\uff08\u5982 Cursor\uff09\u80fd\u591f\u667a\u80fd\u5730\u8bfb\u53d6\u3001\u67e5\u8be2\u548c\u7ba1\u7406 BibTeX \u6587\u732e\u6570\u636e\u5e93\u3002\n\n## \u2728 \u7279\u8272\u4eae\u70b9\n\n- **\ud83d\udcda BibTeX \u652f\u6301** - \u5b8c\u6574\u7684 `.bib` \u6587\u4ef6\u89e3\u6790\u548c\u5904\u7406\n- **\ud83e\udd16 AI \u53cb\u597d** - \u4e13\u4e3a LLM \u8bbe\u8ba1\u7684\u7b80\u6d01 API\n- **\u26a1 \u5373\u5f00\u5373\u7528** - \u4f7f\u7528 `uvx` \u4e00\u952e\u542f\u52a8\uff0c\u65e0\u9700\u590d\u6742\u914d\u7f6e\n- **\ud83d\udd27 Cursor \u96c6\u6210** - \u5b8c\u7f8e\u96c6\u6210\u5230 Cursor \u7f16\u8f91\u5668\u7684 MCP \u7cfb\u7edf\n- **\ud83c\udfaf \u8f7b\u91cf\u9ad8\u6548** - \u4e13\u6ce8\u6838\u5fc3\u529f\u80fd\uff0c\u6027\u80fd\u5353\u8d8a\n\n## \u529f\u80fd\u7279\u6027\n\n### \ud83c\udfaf \u6838\u5fc3\u529f\u80fd\n- **\u8bfb\u53d6\u6587\u4ef6** - \u9ed8\u8ba4\u8fd4\u56de\u6240\u6709key\uff0c\u53ef\u9009\u663e\u793a\u524d5\u6761\u8be6\u7ec6\u4fe1\u606f\n- **\u67e5\u8be2\u6761\u76ee** - \u6839\u636ekey\u83b7\u53d6\u5355\u6761entry\u7684\u8be6\u7ec6\u4fe1\u606f  \n- **\u5199\u5165\u6587\u4ef6** - \u6839\u636ekey\u5217\u8868\u7b5b\u9009\u5e76\u5199\u5165\u65b0\u6587\u4ef6\n\n## \u4f7f\u7528uvx\u8fd0\u884c\n\n### \u5b89\u88c5\u548c\u8fd0\u884c\n```bash\n# \u4ece PyPI \u76f4\u63a5\u8fd0\u884c\uff08\u63a8\u8350\uff09\nuvx bibtex-file-mcp\n\n# \u6216\u8005\u4f7f\u7528\u670d\u52a1\u5668\u540d\u79f0\nuvx --from bibtex-file-mcp bibtex-mcp-server\n\n# \u4ece\u672c\u5730\u9879\u76ee\u8fd0\u884c\nuvx --from . bibtex-mcp-server\n\n# \u6307\u5b9a Python \u7248\u672c\nuvx --python 3.10+ --from bibtex-file-mcp bibtex-file-mcp\n```\n\n### \u4f9d\u8d56\u914d\u7f6e\n\u9879\u76ee\u5df2\u914d\u7f6e `pyproject.toml`\uff0cuvx\u4f1a\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u5b89\u88c5\u3002\n\n## \ud83c\udfaf Cursor \u4e2d\u7684\u914d\u7f6e\n\n### \u65b9\u5f0f\u4e00\uff1a\u4ece PyPI \u5b89\u88c5\uff08\u63a8\u8350\uff09\n\n\u53d1\u5e03\u5230 PyPI \u540e\uff0c\u5728 Cursor \u7684 MCP \u670d\u52a1\u5668\u8bbe\u7f6e\u4e2d\u6dfb\u52a0\u4ee5\u4e0b JSON \u914d\u7f6e\uff1a\n\n```json\n{\n  \"mcpServers\": {\n    \"bibtex-mcp\": {\n      \"command\": \"uvx\",\n      \"args\": [\"bibtex-file-mcp\"]\n    }\n  }\n}\n```\n\n### \u65b9\u5f0f\u4e8c\uff1a\u4ece\u672c\u5730\u9879\u76ee\u8fd0\u884c\n\n\u5982\u679c\u4f60\u60f3\u4ece\u672c\u5730\u9879\u76ee\u8fd0\u884c\uff08\u5f00\u53d1\u6216\u6d4b\u8bd5\uff09\uff0c\u4f7f\u7528\u4ee5\u4e0b\u914d\u7f6e\uff1a\n\n```json\n{\n  \"mcpServers\": {\n    \"bibtex-mcp\": {\n      \"command\": \"uvx\",\n      \"args\": [\n        \"--from\",\n        \"/path/to/your/bibtex_mcp\",\n        \"bibtex-mcp-server\"\n      ],\n      \"env\": {\n        \"PYTHONPATH\": \"/path/to/your/bibtex_mcp\"\n      }\n    }\n  }\n}\n```\n\n### \ud83d\ude80 \u914d\u7f6e\u5b8c\u6210\u540e\u7684\u4f7f\u7528\n\n\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u5728 Cursor \u4e2d\u76f4\u63a5\u4f7f\u7528 BibTeX \u5de5\u5177\uff1a\n\n```\n\u8bf7\u5e2e\u6211\u8bfb\u53d6 references.bib \u6587\u4ef6\u5e76\u663e\u793a\u6240\u6709\u6761\u76ee\u7684 key\n```\n\n```\n\u4ece library.bib \u4e2d\u627e\u5230 key \u4e3a \"smith2024\" \u7684\u6761\u76ee\u8be6\u7ec6\u4fe1\u606f\n```\n\n```\n\u4ece all_papers.bib \u4e2d\u9009\u62e9\u8fd9\u4e9b\u6761\u76ee\uff1a[\"paper1\", \"paper2\", \"paper3\"] \u5e76\u4fdd\u5b58\u5230 selected.bib\n```\n\n## \u53ef\u7528\u5de5\u5177\n\n### 1. `read_bibtex_file(filepath, show_details=False)`\n\u8bfb\u53d6BibTeX\u6587\u4ef6\n\n```python\n# \u83b7\u53d6\u6240\u6709key\uff08\u9ed8\u8ba4\uff09\nread_bibtex_file(\"references.bib\")\n\n# \u663e\u793a\u524d5\u6761\u8be6\u7ec6\u4fe1\u606f\nread_bibtex_file(\"references.bib\", show_details=True)\n```\n\n### 2. `get_bibtex_entry(filepath, key)`\n\u6839\u636ekey\u83b7\u53d6\u5355\u6761\u6761\u76ee\u8be6\u7ec6\u4fe1\u606f\n\n```python\nget_bibtex_entry(\"references.bib\", \"smith2024\")\n```\n\n### 3. `write_bibtex_entries(source_filepath, target_filepath, keys)`\n\u6839\u636ekey\u5217\u8868\u5199\u5165\u9009\u5b9a\u6761\u76ee\u5230\u65b0\u6587\u4ef6\n\n```python\nwrite_bibtex_entries(\n    source_filepath=\"all_refs.bib\",\n    target_filepath=\"selected_refs.bib\", \n    keys=[\"smith2024\", \"doe2023\", \"jones2022\"]\n)\n```\n\n## \u5178\u578b\u5de5\u4f5c\u6d41\u7a0b\n\n1. **\u6d4f\u89c8\u6587\u732e\u5e93**\uff1a\n   ```python\n   # \u67e5\u770b\u6240\u6709\u53ef\u7528\u7684key\n   read_bibtex_file(\"my_library.bib\")\n   ```\n\n2. **\u67e5\u770b\u5177\u4f53\u6761\u76ee**\uff1a\n   ```python\n   # \u67e5\u770b\u611f\u5174\u8da3\u7684\u6761\u76ee\u8be6\u60c5\n   get_bibtex_entry(\"my_library.bib\", \"interesting_paper_2024\")\n   ```\n\n3. **\u521b\u5efa\u5b50\u96c6**\uff1a\n   ```python\n   # \u7b5b\u9009\u76f8\u5173\u8bba\u6587\u5230\u65b0\u6587\u4ef6\n   write_bibtex_entries(\n       \"my_library.bib\", \n       \"project_refs.bib\",\n       [\"paper1_2024\", \"paper2_2023\", \"paper3_2024\"]\n   )\n   ```\n\n## \u9879\u76ee\u7ed3\u6784\n\n```\nbibtex_mcp/\n\u251c\u2500\u2500 bibtex_file_mcp.py    # \u4e3b\u7a0b\u5e8f\n\u251c\u2500\u2500 pyproject.toml        # uvx\u914d\u7f6e\u6587\u4ef6\n\u251c\u2500\u2500 requirements.txt      # \u4f9d\u8d56\u5217\u8868\n\u2514\u2500\u2500 README.md            # \u4f7f\u7528\u8bf4\u660e\n```\n\n## \u7279\u70b9\n\n- **\u8f7b\u91cf\u9ad8\u6548** - \u53ea\u4fdd\u7559\u6838\u5fc3\u529f\u80fd\uff0c\u6ca1\u6709\u5197\u4f59\n- **\u5047\u8bbe\u6b63\u786e** - \u5047\u8bbe\u6240\u6709BibTeX\u683c\u5f0f\u90fd\u662f\u6b63\u786e\u7684\n- **\u7b80\u5355\u89e3\u6790** - \u4f7f\u7528\u7b80\u5355\u6b63\u5219\u8868\u8fbe\u5f0f\u89e3\u6790\n- **uvx\u53cb\u597d** - \u652f\u6301uvx\u4e00\u952e\u8fd0\u884c\u548c\u914d\u7f6e\n\n## \u7cfb\u7edf\u8981\u6c42\n\n- Python 3.10+\n- \u4f9d\u8d56\u5305\uff1a\n  - `mcp>=0.1.0`\n  - `fastmcp>=0.1.0` \n  - `pydantic>=2.0.0`\n\n## \u4f7f\u7528uvx\u7684\u4f18\u52bf\n\n- \u65e0\u9700\u624b\u52a8\u7ba1\u7406\u865a\u62df\u73af\u5883\n- \u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u5b89\u88c5\n- \u4e00\u6b21\u6027\u8fd0\u884c\uff0c\u65e0\u6b8b\u7559\n- \u652f\u6301\u4e0d\u540cPython\u7248\u672c\n\n## \ud83d\udce6 \u5b89\u88c5\u548c\u83b7\u53d6\n\n### \u4ece PyPI \u5b89\u88c5\uff08\u63a8\u8350\uff09\n\n```bash\n# \u76f4\u63a5\u8fd0\u884c\uff0c\u65e0\u9700\u9884\u5b89\u88c5\nuvx bibtex-file-mcp\n\n# \u6216\u8005\u5b89\u88c5\u5230\u7cfb\u7edf\npip install bibtex-file-mcp\nbibtex-file-mcp\n```\n\n### \u4ece\u6e90\u7801\u5b89\u88c5\n\n```bash\n# \u514b\u9686\u4ed3\u5e93\ngit clone https://github.com/Qing25/bibtex-file-mcp.git\ncd bibtex-file-mcp\n\n# \u4ece\u672c\u5730\u8fd0\u884c\nuvx --from . bibtex-mcp-server\n\n# \u6216\u8005\u672c\u5730\u5b89\u88c5\npip install -e .\n```\n\n## \ud83d\udd27 \u5f00\u53d1\u548c\u8d21\u732e\n\n```bash\n# \u514b\u9686\u9879\u76ee\ngit clone https://github.com/Qing25/bibtex-file-mcp.git\ncd bibtex-file-mcp\n\n# \u8bbe\u7f6e\u5f00\u53d1\u73af\u5883\nuv venv\nsource .venv/bin/activate  # Linux/Mac\n# \u6216 .venv\\Scripts\\activate  # Windows\n\n# \u5b89\u88c5\u4f9d\u8d56\nuv pip install -e .\n\n# \u8fd0\u884c\u6d4b\u8bd5\npython test_tools.py\n```\n\n## \ud83d\udcc4 \u8bb8\u53ef\u8bc1\n\nMIT License - \u8be6\u89c1 [LICENSE](LICENSE) \u6587\u4ef6\n\n## \ud83e\udd1d \u8d21\u732e\n\n\u6b22\u8fce\u63d0\u4ea4 Issue \u548c Pull Request\uff01\n\n- GitHub: [https://github.com/Qing25/bibtex-file-mcp](https://github.com/Qing25/bibtex-file-mcp)\n- Issues: [https://github.com/Qing25/bibtex-file-mcp/issues](https://github.com/Qing25/bibtex-file-mcp/issues)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "BibTeX MCP Server for manipulating BibTeX entries",
    "version": "1.1.0",
    "project_urls": {
        "Documentation": "https://github.com/Qing25/bibtex-file-mcp#readme",
        "Homepage": "https://github.com/Qing25/bibtex-file-mcp",
        "Issues": "https://github.com/Qing25/bibtex-file-mcp/issues",
        "Repository": "https://github.com/Qing25/bibtex-file-mcp.git"
    },
    "split_keywords": [
        "bibtex",
        " mcp",
        " bibliography",
        " reference-management",
        " citation",
        " latex"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7c24deefd16d3bb7da61469c40ad4c3d95dad26090c884edfa62243411d8b627",
                "md5": "ceb0b614f90724062b391964a7bd673f",
                "sha256": "421d4317de125181d5e26cca83b8eac438b47125bca3b338a5df84a0b08f58d7"
            },
            "downloads": -1,
            "filename": "bibtex_file_mcp-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ceb0b614f90724062b391964a7bd673f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 7442,
            "upload_time": "2025-09-11T02:24:28",
            "upload_time_iso_8601": "2025-09-11T02:24:28.538311Z",
            "url": "https://files.pythonhosted.org/packages/7c/24/deefd16d3bb7da61469c40ad4c3d95dad26090c884edfa62243411d8b627/bibtex_file_mcp-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "79bd67cf642feefc5f3a8688b6a2bf583226f202834debe0b7fa9d0fe1391c9b",
                "md5": "d6e7ce6c60642a06db8b0001b28484c4",
                "sha256": "799f2ebe8d95f7ef7f71b0e87f325d993f04bc85e5cd1ada8ba6abce974b780f"
            },
            "downloads": -1,
            "filename": "bibtex_file_mcp-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d6e7ce6c60642a06db8b0001b28484c4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 7186,
            "upload_time": "2025-09-11T02:24:29",
            "upload_time_iso_8601": "2025-09-11T02:24:29.919620Z",
            "url": "https://files.pythonhosted.org/packages/79/bd/67cf642feefc5f3a8688b6a2bf583226f202834debe0b7fa9d0fe1391c9b/bibtex_file_mcp-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-11 02:24:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Qing25",
    "github_project": "bibtex-file-mcp#readme",
    "github_not_found": true,
    "lcname": "bibtex-file-mcp"
}
        
Elapsed time: 1.72428s