关于 Metis MCP Tools
Metis MCP Tools 为 Metis RAG 应用提供 MCP 工具,适用于需要数据库、向量存储、文档处理和大模型操作的应用。工具覆盖文档准备、存储到模型交互等环节。
主要功能
- 01PostgreSQL 连接与查询操作
- 02向量集合和文档管理
- 03加载并分析常见文档格式
- 04大模型文本生成与嵌入
适用场景
- 01查看 PostgreSQL 表并执行 SQL 查询
- 02在向量集合中检索相似文档
- 03拆分 PDF、DOCX、TXT 或 MD 文件
- 04使用大模型生成文本或嵌入
MCP 相关
向 MCP 客户端提供数据库、向量存储、文档处理和大模型交互工具。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
Metis MCP 工具
此代码库包含一组 Model Context Protocol (MCP) 工具,旨在增强 Metis RAG 应用。这些工具提供数据库管理、向量存储操作、文档处理和 LLM 交互功能。
什么是 MCP?
Model Context Protocol (MCP) 是一种标准化方式,可让语言模型与外部工具和资源交互。借助它,模型能够访问数据、执行操作,并使用超出其训练数据范围的专用能力。
工具概览
此代码库包含以下 MCP 工具:
1. 数据库管理工具
数据库管理工具提供了在 Metis 应用中与 PostgreSQL 数据库交互的功能。
功能:
- 初始化数据库连接
- 执行 SQL 查询
- 获取表结构
- 列出数据库表
使用示例:
// Initialize a database connection
const dbResult = await useMcpTool({
serverName: 'database-tool',
toolName: 'init_database_connection',
arguments: {
host: 'localhost',
port: 5432,
database: 'metis_db',
user: 'metis_user',
password: 'password123'
}
});
// Execute a query
const queryResult = await useMcpTool({
serverName: 'database-tool',
toolName: 'execute_query',
arguments: {
query: 'SELECT * FROM documents LIMIT 10'
}
});
2. 向量存储工具
向量存储工具提供了在 Metis 应用中与 Chroma 等向量数据库交互的功能。
功能:
- 初始化向量存储连接
- 创建和管理集合
- 向集合添加文档
- 查询集合以查找相似文档
- 从集合中删除文档
使用示例:
// Initialize a vector store connection
const vsResult = await useMcpTool({
serverName: 'vector-store-tool',
toolName: 'init_vector_store',
arguments: {
host: 'localhost',
port: 8000
}
});
// Create a collection
const collectionResult = await useMcpTool({
serverName: 'vector-store-tool',
toolName: 'get_or_create_collection',
arguments: {
name: 'metis_documents'
}
});
// Query the collection
const queryResult = await useMcpTool({
serverName: 'vector-store-tool',
toolName: 'query_collection',
arguments: {
queryTexts: ['How does quantum computing work?'],
nResults: 5
}
});
3. 文档处理工具
文档处理工具提供了在 Metis 应用中加载、处理和分块文档的功能。
功能:
- 加载各种文件格式的文档(PDF、DOCX、TXT、MD)
- 将文档拆分为多个块以供处理
- 从文档中提取代码块
- 分析文档结构
使用示例:
// Load a document
const docResult = await useMcpTool({
serverName: 'document-processing-tool',
toolName: 'load_document',
arguments: {
filePath: '/path/to/document.pdf'
}
});
// Chunk the document
const chunkResult = await useMcpTool({
serverName: 'document-processing-tool',
toolName: 'chunk_document',
arguments: {
text: docResult.document.pageContent,
chunkSize: 1000,
chunkOverlap: 200,
metadata: docResult.document.metadata
}
});
4. LLM 交互工具
LLM 交互工具提供了在 Metis 应用中与语言模型交互的功能。
功能:
- 初始化来自各种提供商(OpenAI、Anthropic)的 LLM 模型
- 使用 LLM 生成文本
- 使用提示词模板进行结构化生成
- 为文本生成嵌入
使用示例:
// Initialize an LLM model
const llmResult = await useMcpTool({
serverName: 'llm-interaction-tool',
toolName: 'init_llm_model',
arguments: {
modelId: 'gpt4',
provider: 'openai',
modelName: 'gpt-4',
apiKey: 'your-api-key',
temperature: 0.7
}
});
// Generate text with a prompt template
const genResult = await useMcpTool({
serverName: 'llm-interaction-tool',
toolName: 'use_prompt_template',
arguments: {
modelId: 'gpt4',
template: 'Summarize the following text: {text}',
variables: {
text: 'Long document content here...'
}
}
});
安装和设置
要在 Metis 应用中使用这些 MCP 工具:
-
克隆此代码库:
git clone https://github.com/dagron78/metis-mcp-demo.git -
安装依赖项:
cd metis-mcp-demo npm install -
启动所需的 MCP 服务:
node tools/database-tool.js node tools/vector-store-tool.js node tools/document-processing-tool.js node tools/llm-interaction-tool.js -
使用 MCP 客户端从应用连接到 MCP 服务。
贡献
欢迎贡献!欢迎提交拉取请求或提出问题,以改进这些工具或添加新工具。
许可证
MIT
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。