Skip to main content
Glama
yadu0323

AI Document Assistant MCP Server

by yadu0323

AI Document Assistant

一个基于 RAG(检索增强生成)FAISSMCP(模型上下文协议)OllamaStreamlit 构建的 AI 文档助手。

上传 PDF 文档,询问文档内容相关问题,生成摘要,提取关键词,并通过 Wikipedia 集成回答常识性问题。


功能特性

文档问答

  • 就上传的 PDF 文档提出问题。

  • 使用 FAISS 向量搜索检索相关文档片段。

  • 使用 Ollama 生成自然语言回答。

文档摘要

  • 生成上传文档的简明摘要。

关键词提取

  • 从文档中提取重要关键词和主题。

常识性问题

  • 集成 Wikipedia 回答上传文档之外的问题。

MCP 集成

  • 通过 MCP 暴露工具。

  • 支持通过 MCP 客户端进行工具发现和执行。

PDF 上传支持

  • 直接从 Streamlit 界面上传 PDF 文件。

  • 自动创建嵌入并为文档建立索引以便检索。

Streamlit 界面

  • 简单易用的聊天界面。

  • 实时上传 PDF 并与文档交互。


架构

PDF
 │
 ▼
PDF Loader
 │
 ▼
Text Chunking
 │
 ▼
Embeddings
 │
 ▼
FAISS Vector Store
 │
 ▼
Retrieval
 │
 ▼
LLM (Ollama)
 │
 ▼
Answer Generation

技术栈

后端

  • Python

LLM

  • Ollama

  • Qwen 2.5 Coder 7B

向量数据库

  • FAISS

嵌入

  • Sentence Transformers

协议

  • MCP(模型上下文协议)

前端

  • Streamlit

外部知识

  • Wikipedia API


项目结构

AI-Document-Assistant/
│
├── datas/
│
├── src/
│   ├── pdf_loader.py
│   ├── chunker.py
│   ├── embeddings.py
│   ├── vector_store.py
│   └── rag_store.py
│
├── tools/
│   ├── search_tool.py
│   ├── summary_tool.py
│   ├── keyword_tool.py
│   ├── qa_tool.py
│   └── wiki_tool.py
│
├── app.py
├── agent.py
├── build_rag.py
├── mcp_client.py
├── mcp_server.py
├── requirements.txt
├── README.md
└── .gitignore

安装

克隆仓库

git clone https://github.com/yourusername/AI-Document-Assistant.git

cd AI-Document-Assistant

创建虚拟环境

python -m venv .venv

激活环境

Windows:

.venv\Scripts\activate

Linux/macOS:

source .venv/bin/activate

安装依赖

pip install -r requirements.txt

安装 Ollama

下载并安装 Ollama:

https://ollama.com

拉取模型:

ollama pull qwen2.5-coder:7b

启动 Ollama:

ollama serve

运行应用程序

streamlit run app.py

打开:

http://localhost:8501

工作原理

文档问题

示例:

What is MySQL Workbench?

助手将:

  1. 搜索相关文档片段。

  2. 使用 FAISS 检索匹配的上下文。

  3. 将上下文发送给 Ollama。

  4. 生成最终回答。


常识性问题

示例:

Who is Elon Musk?

助手将:

  1. 检测问题是否与文档无关。

  2. 使用 Wikipedia。

  3. 返回简明回答。


MCP 工具

可用的 MCP 工具:

document_search

搜索相关文档片段。

document_summary

生成文档摘要。

document_keywords

提取重要关键词。

ask_document

对上传的文档进行问答。

wiki_search

使用 Wikipedia 进行常识性知识查询。


未来改进

  • 多 PDF 支持

  • 聊天历史记忆

  • 对话上下文

  • 来源引用

  • 混合搜索(BM25 + 向量搜索)

  • 持久化向量数据库

  • Docker 部署

  • 身份验证和用户管理



作者

Yadu


-
license - not tested
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yadu0323/AI-Document-Assistant'

If you have feedback or need assistance with the MCP directory API, please join our Discord server