Metadata-Version: 2.1
Name: zhdddd-mcp-knowledge-server
Version: 0.1.1
Summary: 基于FastAPI的本地知识库MCP服务器，集成FAISS向量库
Home-page: https://github.com/yourusername/mcp-knowledge-server
Author: Your Name
Author-email: Your Name <your.email@example.com>
License: MIT License
        
        Copyright (c) 2026 MCP Knowledge Server
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi==0.104.1
Requires-Dist: uvicorn[standard]==0.23.2
Requires-Dist: faiss-cpu>=1.8.0
Requires-Dist: numpy==1.26.4
Requires-Dist: packaging==24.0
Requires-Dist: python-multipart==0.0.6
Requires-Dist: pydantic==2.5.2
Requires-Dist: pydantic-settings==2.1.0
Requires-Dist: python-dotenv==1.0.0

# zhdddd-mcp-knowledge-server

基于FastAPI的本地知识库MCP服务器，集成FAISS向量库，支持文档上传、向量检索和MCP协议接口。

## 功能特性

- **文档上传与解析**：支持上传文档并自动拆分为文本块，提高检索精度
- **向量检索**：使用FAISS向量库实现高效的相似度搜索
- **MCP协议接口**：支持标准的MCP协议，供大模型调用
- **工具列表与调用**：实现了`/tools/list`和`/tools/call`接口，符合MCP规范
- **健康检查**：提供服务健康状态检查接口

## 安装方法

### 从PyPI安装

```bash
pip install zhdddd-mcp-knowledge-server
```

### 使用uvx启动

```bash
uvx zhdddd-mcp-knowledge-server
```

## 快速开始

1. **启动服务器**：
   ```bash
   zhdddd-mcp-knowledge-server
   ```
   或使用uvx：
   ```bash
   uvx zhdddd-mcp-knowledge-server
   ```

2. **服务默认运行在**：
   ```
   http://0.0.0.0:8000
   ```

## 主要接口

### 健康检查
- **GET** `/health` - 检查服务状态

### 文档上传
- **POST** `/upload/document` - 上传文档并解析入库

### 向量检索
- **POST** `/retrieve` - 检索相似文档

### MCP协议接口
- **POST** `/mcp/invoke` - MCP协议调用接口
- **GET** `/mcp/info` - 服务信息和工具列表

### 工具接口（标准MCP规范）
- **GET** `/tools/list` - 获取可用工具列表
- **POST** `/tools/call` - 调用指定工具

### 集合信息
- **GET** `/collection/info` - 获取知识库信息

## 示例使用

### 上传文档

```bash
curl -X POST "http://localhost:8000/upload/document" \
  -F "file=@example.txt"
```

### 检索文档

```bash
curl -X POST "http://localhost:8000/retrieve" \
  -H "Content-Type: application/json" \
  -d '{"query": "ESOP是什么"}'
```

### MCP工具调用

```bash
curl -X POST "http://localhost:8000/tools/call" \
  -H "Content-Type: application/json" \
  -d '{"tool": "retrieve_knowledge", "parameters": {"query": "ESOP是什么"}}'
```

## 配置说明

服务默认配置：
- 主机：0.0.0.0
- 端口：8000
- 向量维度：768
- 文档拆分大小：500字符
- 文本块重叠：100字符

## 依赖项

- fastapi
- uvicorn
- faiss-cpu
- numpy
- packaging
- python-multipart
- pydantic
- pydantic-settings
- python-dotenv

## 许可证

MIT License
