Metadata-Version: 2.4
Name: library-nudt-mcp
Version: 1.4.0
Summary: 国防科技大学图书馆 MCP 服务器 - 提供学术资源检索功能
Author-email: connor <connor@users.noreply.github.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/connor/library-nudt-mcp
Project-URL: Documentation, https://github.com/connor/library-nudt-mcp#readme
Project-URL: Repository, https://github.com/connor/library-nudt-mcp.git
Project-URL: Issues, https://github.com/connor/library-nudt-mcp/issues
Keywords: mcp,library,search,academic,nudt
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastmcp>=0.1.0
Requires-Dist: requests>=2.28.0
Requires-Dist: beautifulsoup4>=4.12.0
Requires-Dist: DrissionPage>=4.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: flake8>=6.0.0; extra == "dev"
Dynamic: license-file

# library-nudt-mcp

国防科技大学图书馆 MCP 服务器 - 提供学术资源检索功能

## 功能特性

- 🔍 专业的学术资源检索（期刊、图书、专利、标准、学位论文等）
- 📚 支持复杂的检索表达式（布尔逻辑、字段限定、年份范围）
- 🎯 精确的检索表达式验证器
- 🔐 Cookie 管理与自动续期
- 🚀 基于 FastMCP 框架，支持 stdio 模式
- 🔄 搜索失败自动重试（最多 2 次）
- 🤖 Cookie 失效时自动尝试 headless 登录
- ⚡ MCP 服务器启动不阻塞（Cookie 检测异步化）

## 安装

```bash
pip install library-nudt-mcp
```

## 快速开始

### 1. 作为 MCP 服务器使用

在 VS Code 的 MCP 配置中添加：

```json
{
  "servers": {
    "libnudt": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "library-nudt-mcp",
        "library-nudt-mcp"
      ]
    }
  }
}
```

### 2. 作为 Python 库使用

```python
from library_nudt_mcp import nudt_search

# 执行检索
result = nudt_search(expression="K='导航|制导|控制'", page=1, size=20)
print(result)
```

## 检索表达式语法

### 字段代码

| 字段 | 含义 | 字段 | 含义 |
|------|------|------|------|
| T | 标题 | A | 作者 |
| K | 关键词 | S | 摘要 |
| O | 作者单位 | Y | 年份 |
| Z | 全字段 | Su | 主题词 |

### 文献类型限定

| 前缀 | 类型 | 前缀 | 类型 |
|------|------|------|------|
| JN | 期刊 | BK | 图书 |
| DT | 学位论文 | CP | 会议论文 |
| PT | 专利 | ST | 标准 |

### 逻辑运算符

- `AND` - 与
- `OR` - 或
- `NOT` - 非

### 示例

```python
# 简单检索
nudt_search("A='张三'")

# 多条件检索
nudt_search("A='张三' AND K='水资源'")

# 年份范围
nudt_search("A='张三' AND 2000<Y<2020")

# 限定期刊
nudt_search("JN(A='杨振宁|周培源' AND O='清华大学')")

# 复杂组合
nudt_search("JN((A='杨振宁|周培源' AND O='清华大学') OR A='钱学森' AND 2000<Y<2016 NOT K='断层')")
```

## 可靠性

- 搜索请求失败时自动重试（指数退避）
- Cookie 失效时自动尝试 headless 登录恢复
- MCP 服务器启动不阻塞，首次工具调用时按需登录
- Cookie 文件损坏/缺失时优雅降级

## 开发

```bash
git clone https://github.com/connor/library-nudt-mcp.git
cd library-nudt-mcp
pip install -e ".[dev]"
pytest
```

## 许可证

MIT License
