Skip to main content

BibTeX MCP Server for manipulating BibTeX entries

Project description

BibTeX MCP Server

PyPI version Python 3.10+ License: MIT MCP Compatible

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

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

✨ 特色亮点

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

功能特性

🎯 核心功能

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

使用uvx运行

安装和运行

# 从 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 配置:

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

方式二:从本地项目运行

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

{
  "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文件

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

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

2. get_bibtex_entry(filepath, key)

根据key获取单条条目详细信息

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

3. write_bibtex_entries(source_filepath, target_filepath, keys)

根据key列表写入选定条目到新文件

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

典型工作流程

  1. 浏览文献库

    # 查看所有可用的key
    read_bibtex_file("my_library.bib")
    
  2. 查看具体条目

    # 查看感兴趣的条目详情
    get_bibtex_entry("my_library.bib", "interesting_paper_2024")
    
  3. 创建子集

    # 筛选相关论文到新文件
    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 安装(推荐)

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

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

从源码安装

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

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

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

🔧 开发和贡献

# 克隆项目
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 文件

🤝 贡献

欢迎提交 Issue 和 Pull Request!

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

bibtex_file_mcp-1.0.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

bibtex_file_mcp-1.0.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file bibtex_file_mcp-1.0.1.tar.gz.

File metadata

  • Download URL: bibtex_file_mcp-1.0.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bibtex_file_mcp-1.0.1.tar.gz
Algorithm Hash digest
SHA256 83d84daec04c98270c09bb4bf0b40dd40d5838fa55546af80ed48150766536e5
MD5 416f6a43cfc2e5afae88e8a426cf936a
BLAKE2b-256 c5eaae19cfabb4d4f5276f872b2570898f937fc91b55d712da10773c67b6645e

See more details on using hashes here.

Provenance

The following attestation bundles were made for bibtex_file_mcp-1.0.1.tar.gz:

Publisher: publish.yml on Qing25/bibtex-file-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bibtex_file_mcp-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bibtex_file_mcp-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4bf31a1422011e48fdd3010d87494e6beafe75e06f7a8f8c4098bf463bb57336
MD5 8a7ffbad42632ed7abf9ad785b2e3916
BLAKE2b-256 5ab1e5952a77771a6e6bf016f3daf4eea2af77e8eb7f371d83369829676cfaaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for bibtex_file_mcp-1.0.1-py3-none-any.whl:

Publisher: publish.yml on Qing25/bibtex-file-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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