使用说明
项目简介
本项目是一个基于 Model Context Protocol (MCP) 的服务器实现,专注于提供内容摘要功能。它利用 Google Gemini 1.5 Pro 模型,能够对多种类型的内容进行智能概括,帮助用户快速获取文章、网页、文档等内容的核心信息。
主要功能点
- 通用内容摘要: 支持多种内容格式,包括纯文本、网页链接、PDF文档、EPUB书籍和HTML内容。
- 智能模型驱动: 采用 Google Gemini 1.5 Pro 模型,保证摘要质量和信息准确性。
- 可定制摘要: 允许用户自定义摘要的最大长度、目标语言、关注焦点和摘要风格。
- 动态示例资源: 提供一个简单的动态 greeting 资源用于测试 MCP 服务器的基本功能。
安装步骤
- 克隆仓库
git clone https://github.com/0xshellming/mcp-summarizer.git cd mcp-summarizer - 安装依赖
确保已安装 pnpm 包管理器,然后运行:
pnpm install - 构建项目
pnpm run build - 启动服务器
服务器默认通过标准输入/输出 (stdio) 与 MCP 客户端通信。pnpm start
服务器配置
MCP 客户端需要配置以下 JSON 格式信息以连接到内容摘要服务器。请注意,您需要将 '{ABSOLUTE PATH TO FILE HERE}' 替换为 'dist/index.js' 文件的绝对路径。
{ "mcpServers": { "content-summarizer": { "command": "node", "args": [ "{ABSOLUTE PATH TO FILE HERE}/dist/index.js" ] } } }
配置参数说明:
- '"content-summarizer"': 服务器名称,客户端用此名称引用该服务器。
- '"command": "node"': 启动服务器的命令,这里使用 Node.js 运行时。
- '"args": ["{ABSOLUTE PATH TO FILE HERE}/dist/index.js"]': 启动命令的参数,指向编译后的服务器入口文件 'dist/index.js' 的绝对路径。 请务必替换为实际的绝对路径。
基本使用方法
本服务器提供以下工具 (Tools) 和资源 (Resources):
工具 (Tools):
-
'summarize': 用于生成内容摘要。
调用示例 (假设 MCP 客户端已连接到名为 'content-summarizer' 的服务器):
// 摘要网页内容 const webSummary = await client.invoke("content-summarizer", "summarize", { content: "https://example.com/article", type: "url", maxLength: 250, style: "concise" }); console.log("网页摘要:", webSummary); // 摘要 PDF 文档 (base64 编码) const pdfSummary = await client.invoke("content-summarizer", "summarize", { content: pdfBase64String, // 替换为 PDF 文件的 base64 编码字符串 type: "pdf", language: "zh", focus: "主要论点" }); console.log("PDF 摘要:", pdfSummary);'summarize' 工具参数说明:
- 'content': 要摘要的内容,可以是文本字符串、网页 URL、Base64 编码的 PDF 或 EPUB 文件内容。
- 'type': 内容类型,可选值包括 '"text"', '"url"', '"pdf"', '"epub"'。
- 'maxLength' (可选): 摘要的最大长度(字符数),默认为 200。
- 'language' (可选): 摘要的目标语言,默认为 '"en"' (英语)。
- 'focus' (可选): 摘要的关注焦点,例如 "关键发现", "主要结论" 等。
- 'style' (可选): 摘要风格,例如 '"concise"' (简洁), '"detailed"' (详细), '"bullet-points"' (要点列表) 等。
资源 (Resources):
-
'greeting://{name}': 动态问候资源,用于演示资源功能。
访问示例 (假设 MCP 客户端已连接到名为 'content-summarizer' 的服务器):
const greeting = await client.getResource("content-summarizer", "greeting://World"); console.log("问候语:", greeting); // 输出: Hello, World!将 '{name}' 替换为您想要问候的名字即可。
通过以上步骤,您可以成功安装、配置和使用 Content Summarizer Server,为您的 MCP 客户端应用提供强大的内容摘要能力。
信息
分类
AI与计算