Summarization MCP server

Provides summarized output from various actions, optimizing token usage for efficient processing of large datasets and language models.
Back to servers
Setup instructions
Provider
Remi Sebastian Kits
Release date
Dec 26, 2024
Language
TypeScript
Package
Stats
748 downloads
34 stars

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.

Installation Options

Using Smithery for Claude Desktop

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

Using npm

npm i mcp-summarization-functions

Configuration

The server requires configuration through environment variables to connect to an AI provider.

Required Environment Variables

  • PROVIDER: Choose from ANTHROPIC, OPENAI, OPENAI-COMPATIBLE, or GOOGLE
  • API_KEY: Your API key for the selected provider

Optional Environment Variables

  • MODEL_ID: Specific model identifier (defaults to provider's standard model)
  • PROVIDER_BASE_URL: Custom API endpoint for OpenAI-compatible providers
  • MAX_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

Example Configurations

# 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

Usage

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"
            }
        }
    }
}

Available Functions

summarize_command

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")
}

summarize_files

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")
}

summarize_directory

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")
}

summarize_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")
}

get_full_content

Retrieves the full content for a given summary ID.

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

AI Agent Integration

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.

How to install this MCP server

For Claude Code

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.

For Cursor

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.

Adding an MCP server to Cursor globally

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"
            }
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.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

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later