mcpField
S
Summarization Functions

Summarization Functions

本地服务
github.com/BraffolkAI 与智能体3771 周前更新

关于 Summarization Functions

Summarization Functions 是一个 MCP 服务,用于将命令输出、文件内容、目录结构和任意文本压缩为摘要,以减少 AI Agent 的上下文占用。它主要面向 Cline、Roo Cline 等编码 Agent,并支持多个模型提供商。

主要功能

  1. 01命令输出摘要
  2. 02单个或多个文件内容分析
  3. 03目录结构概览
  4. 04任意文本摘要与完整内容检索
  5. 05可配置的模型提供商与缓存时长

适用场景

  1. 01减少 Agent 读取大型文件时的上下文占用
  2. 02压缩长日志、命令输出或 API 响应
  3. 03快速了解陌生项目的目录结构

MCP 相关

该项目是 MCP 服务端,向 MCP 客户端提供 summarize_command、summarize_files、summarize_directory、summarize_text 和 get_full_content 等工具。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

摘要功能

为 Model Context Protocol 提供智能文本摘要

功能 • AI Agent 集成 • 安装 • 用法

smithery badge npm version


概述

一款功能强大的 MCP 服务,通过简洁且易于扩展的架构提供智能摘要功能。使用现代 TypeScript 构建,旨在与 AI 工作流无缝集成。

安装

通过 Smithery 安装

要通过 Smithery 自动为 Claude Desktop 安装 Summarization Functions:

npx -y @smithery/cli install mcp-summarization-functions --client claude
npm i mcp-summarization-functions

AI Agent 集成

开发此 MCP 服务主要是为了提升 Roo Cline 和 Cline 等 AI Agent 的性能与可靠性。它解决了 AI Agent 运行中的一项关键挑战:上下文窗口管理。

上下文窗口优化

AI Agent 经常遇到上下文窗口被大量输出迅速填满的情况,例如:

  • 命令执行结果
  • 文件内容读取结果
  • 目录列表
  • API 响应
  • 错误消息和堆栈跟踪

此服务通过以下方式帮助高效利用上下文:

  1. 提供简洁且相关的摘要,而非完整内容
  2. 存储完整内容,以便在需要时查阅
  3. 根据特定需求(安全性、API 范围等)提供重点分析
  4. 支持多种输出格式,以优化上下文利用率
对 AI Agent 的益处
  • 降低失败率:防止上下文窗口溢出
  • 提升响应质量:提供重点突出且相关的摘要
  • 提高效率:减少冗余,同时保留重要上下文
  • 更好地管理资源:通过智能内容缓存和检索
  • 灵活集成:支持多种 AI 提供商和配置选项
推荐的 AI Agent 提示词

与 AI Agent 集成时,请在 Agent 的指令中加入以下内容:

# CONTEXT MANAGEMENT

You have access to summarization functions through the MCP server. These functions are NOT optional - you MUST use them for ALL potentially large outputs to prevent context overflow:

MANDATORY SUMMARIZATION:
- You MUST ALWAYS use summarization functions for:
    - ANY first time file reading operations (unless you are CERTAIN its small and you are going to edit it)
    - ALL command execution outputs
    - EVERY directory analysis
    - ANY API responses or error logs
    - ANY output that could be large

NEVER attempt to process raw output directly - ALWAYS use the appropriate summarization function:
• For commands: summarize_command
• For files: summarize_files
• For directories: summarize_directory
• For other text: summarize_text

ALWAYS utilize available features:
• Specify hints for focused analysis
• Choose appropriate output formats
• Use content IDs to access full details only when absolutely necessary

There is NO NEED to process perfect or complete output. Summarized content is ALWAYS preferred over raw data. When in doubt, use summarization.

Ollama 仓库中的摘要功能演示(使用 Gemini 2.0 Flash 生成摘要,Claude 3.5 作为 Agent)

替代文本

功能

  • 命令输出摘要
    执行命令并获取简洁的输出摘要

  • 文件内容分析
    对单个或多个文件进行摘要,同时保持技术准确性

  • 理解目录结构
    清晰概览复杂的目录结构

  • 灵活的模型支持 使用不同提供商的模型

  • 优化 AI Agent 上下文 通过智能摘要避免上下文窗口溢出,并提升 AI Agent 性能

配置

此服务通过环境变量支持多种 AI 提供商:

必需的环境变量
  • PROVIDER:要使用的 AI 提供商。支持的值: - ANTHROPIC - Anthropic 的 Claude 模型 - OPENAI - OpenAI 的 GPT 模型 - OPENAI-COMPATIBLE - 兼容 OpenAI 的 API(例如 Azure) - GOOGLE - Google 的 Gemini 模型
  • API_KEY:所选提供商的 API 密钥
可选的环境变量
  • MODEL_ID:要使用的特定模型(默认为提供商的标准模型)
  • PROVIDER_BASE_URL:兼容 OpenAI 的提供商所使用的自定义 API 端点
  • MAX_TOKENS:模型响应的最大 token 数(默认值:1024)
  • SUMMARIZATION_CHAR_THRESHOLD:触发摘要的字符数阈值(默认值:512)
  • SUMMARIZATION_CACHE_MAX_AGE:缓存时长,单位为毫秒(默认值:3600000,即 1 小时)
  • MCP_WORKING_DIR - 用于尝试查找相对路径文件的备用目录
配置示例
# Anthropic Configuration
PROVIDER=ANTHROPIC
API_KEY=your-anthropic-key
MODEL_ID=claude-3-5-sonnet-20241022

# OpenAI Configuration
PROVIDER=OPENAI
API_KEY=your-openai-key
MODEL_ID=gpt-4-turbo-preview

# Azure OpenAI Configuration
PROVIDER=OPENAI-COMPATIBLE
API_KEY=your-azure-key
PROVIDER_BASE_URL=https://your-resource.openai.azure.com
MODEL_ID=your-deployment-name

# Google Configuration
PROVIDER=GOOGLE
API_KEY=your-google-key
MODEL_ID=gemini-2.0-flash-exp

用法

将该服务添加到 MCP 配置文件中:

{
		"mcpServers": {
				"MUST_USE_summarization": {
						"command": "node",
						"args": ["path/to/summarization-functions/build/index.js"],
						"env": {
								"PROVIDER": "ANTHROPIC",
								"API_KEY": "your-api-key",
								"MODEL_ID": "claude-3-5-sonnet-20241022",
                "MCP_WORKING_DIR": "default_working_directory"
						}
				}
		}
}
可用函数

该服务提供以下摘要工具:

summarize_command

执行命令并汇总输出。

{
  // Required
  command: string,    // Command to execute
  cwd: string,       // Working directory for command execution
  
  // Optional
  hint?: string,      // Focus area: "security_analysis" | "api_surface" | "error_handling" | "dependencies" | "type_definitions"
  output_format?: string  // Format: "text" | "json" | "markdown" | "outline" (default: "text")
}
summarize_files

汇总文件内容。

{
  // Required
  paths: string[],    // Array of file paths to summarize (relative to cwd)
  cwd: string,       // Working directory for resolving file paths
  
  // Optional
  hint?: string,      // Focus area: "security_analysis" | "api_surface" | "error_handling" | "dependencies" | "type_definitions"
  output_format?: string  // Format: "text" | "json" | "markdown" | "outline" (default: "text")
}
summarize_directory

获取目录结构概览。

{
  // Required
  path: string,       // Directory path to summarize (relative to cwd)
  cwd: string,       // Working directory for resolving directory path
  
  // Optional
  recursive?: boolean,  // Whether to include subdirectories. Safe for deep directories
  hint?: string,       // Focus area: "security_analysis" | "api_surface" | "error_handling" | "dependencies" | "type_definitions"
  output_format?: string   // Format: "text" | "json" | "markdown" | "outline" (default: "text")
}
summarize_text

汇总任意文本内容。

{
  // Required
  content: string,    // Text content to summarize
  type: string,       // Type of content (e.g., "log output", "API response")
  
  // Optional
  hint?: string,      // Focus area: "security_analysis" | "api_surface" | "error_handling" | "dependencies" | "type_definitions"
  output_format?: string  // Format: "text" | "json" | "markdown" | "outline" (default: "text")
}
get_full_content

获取指定摘要 ID 对应的完整内容。

{
  // Required
  id: string         // ID of the stored content
}

运行评测

evals 包会加载一个 MCP 客户端,然后运行 index.ts 文件,因此测试之间无需重新构建。可以在 npx 命令前添加环境变量来加载它们。完整文档请参阅 这里。

OPENAI_API_KEY=your-key  npx mcp-eval src/evals/evals.ts src/server/mcp-server.ts

许可证

MIT

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。