The MCP Summarization Functions server provides intelligent text summarization capabilities designed to optimize AI agent context windows. This server helps AI agents manage large outputs from commands, files, directories, and API responses by providing concise summaries while maintaining access to full content when needed.
npx -y @smithery/cli install mcp-summarization-functions --client claude
npm i mcp-summarization-functions
The server requires configuration through environment variables to connect to an AI provider.
PROVIDER
: Choose from ANTHROPIC
, OPENAI
, OPENAI-COMPATIBLE
, or GOOGLE
API_KEY
: Your API key for the selected providerMODEL_ID
: Specific model identifier (defaults to provider's standard model)PROVIDER_BASE_URL
: Custom API endpoint for OpenAI-compatible providersMAX_TOKENS
: Maximum tokens for responses (default: 1024)SUMMARIZATION_CHAR_THRESHOLD
: Character threshold for summarization (default: 512)SUMMARIZATION_CACHE_MAX_AGE
: Cache duration in milliseconds (default: 3600000 - 1 hour)MCP_WORKING_DIR
: Fallback directory for resolving relative file paths# 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
Add the server to your MCP configuration file:
{
"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"
}
}
}
}
Executes and summarizes command output.
{
// 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")
}
Summarizes file contents.
{
// 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")
}
Gets directory structure overview.
{
// 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")
}
Summarizes arbitrary text content.
{
// 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")
}
Retrieves the full content for a given summary ID.
{
// Required
id: string // ID of the stored content
}
When integrating with AI agents, include these instructions in your agent's prompt:
# 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.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "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"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"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"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"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"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect