Slimcontext Mcp Server

io.github.agentailorPublished by GitHub account agentailorv0.1.2Updated Oct 24, 2026

MCP Server for SlimContext - AI chat history compression tools

VerifiedSTDIODesktop onlyDeveloper ToolsAI & ML

Overview

AI-generated overview

Local MCP server wrapping the SlimContext library, giving assistants two tools to compress AI chat history by trimming or summarizing messages.

What you can do
  • Compress chat history by token-based trimming, dropping the oldest non-system messages until under a token threshold
  • Compress chat history by AI summarization, condensing the middle of a conversation into a summary message
  • Tune compression with parameters for model token window, threshold percentage, minimum recent messages, OpenAI model and a custom summarization prompt
  • Return structured results with original and compressed message counts, messages removed and compression ratio, or structured error responses
When to use it
Useful when a conversation grows past a model's context window and you want the assistant to shrink it before continuing, either deterministically without external calls or with an AI-generated summary of older turns.
Requirements
Runs locally over stdio, typically launched with npx from the npm package slimcontext-mcp-server (Node.js). The summarization tool needs an OpenAI API key, supplied through the OPENAI_API_KEY environment variable or the openaiApiKey tool parameter, plus network access to OpenAI.
Before you install
The summarization tool sends the middle portion of the conversation to OpenAI, so chat content leaves the machine; the API key can be passed as a tool parameter or environment variable. Trimming permanently drops older messages from the returned history, and token counts are a rough heuristic rather than exact.

Installation

In SourceWeft

  1. Open Slimcontext Mcp Server in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

SlimContext MCP Server

A Model Context Protocol (MCP) server that wraps the SlimContext library, providing AI chat history compression tools for MCP-compatible clients.

Overview

SlimContext MCP Server exposes two powerful compression strategies as MCP tools:

  1. trim_messages - Token-based compression that removes oldest messages when exceeding token thresholds
  2. summarize_messages - AI-powered compression using OpenAI to create concise summaries

Installation

bash
npm install -g slimcontext-mcp-server# orpnpm add -g slimcontext-mcp-server

Development

bash
# Clone and setupgit clone <repository>cd slimcontext-mcp-serverpnpm install
# Buildpnpm build
# Run in developmentpnpm dev
# Type checkingpnpm typecheck

Configuration

MCP Client Setup

Add to your MCP client configuration:

json
{  "mcpServers": {    "slimcontext": {      "command": "npx",      "args": ["-y", "slimcontext-mcp-server"]    }  }}

Environment Variables

  • OPENAI_API_KEY: OpenAI API key for summarization (optional, can be passed as tool parameter)

Tools

trim_messages

Compresses chat history using token-based trimming strategy.

Parameters:

  • messages (required): Array of chat messages
  • maxModelTokens (optional): Maximum model token context window (default: 8192)
  • thresholdPercent (optional): Percentage threshold to trigger compression 0-1 (default: 0.7)
  • minRecentMessages (optional): Minimum recent messages to preserve (default: 2)

Example:

json
{  "messages": [    { "role": "system", "content": "You are a helpful assistant." },    { "role": "user", "content": "Hello!" },    { "role": "assistant", "content": "Hi there! How can I help you today?" },    { "role": "user", "content": "Tell me about AI." }  ],  "maxModelTokens": 4000,  "thresholdPercent": 0.8,  "minRecentMessages": 2}

Response:

json
{  "success": true,  "original_message_count": 4,  "compressed_message_count": 3,  "messages_removed": 1,  "compression_ratio": 0.75,  "compressed_messages": [    { "role": "system", "content": "You are a helpful assistant." },    { "role": "assistant", "content": "Hi there! How can I help you today?" },    { "role": "user", "content": "Tell me about AI." }  ]}

summarize_messages

Compresses chat history using AI-powered summarization strategy.

Parameters:

  • messages (required): Array of chat messages
  • maxModelTokens (optional): Maximum model token context window (default: 8192)
  • thresholdPercent (optional): Percentage threshold to trigger compression 0-1 (default: 0.7)
  • minRecentMessages (optional): Minimum recent messages to preserve (default: 4)
  • openaiApiKey (optional): OpenAI API key (can also use OPENAI_API_KEY env var)
  • openaiModel (optional): OpenAI model for summarization (default: 'gpt-4o-mini')
  • customPrompt (optional): Custom summarization prompt

Example:

json
{  "messages": [    { "role": "system", "content": "You are a helpful assistant." },    { "role": "user", "content": "I want to build a web scraper." },    {      "role": "assistant",      "content": "I can help you build a web scraper! What programming language would you prefer?"    },    { "role": "user", "content": "Python please." },    {      "role": "assistant",      "content": "Great choice! For Python web scraping, I recommend using requests and BeautifulSoup..."    },    { "role": "user", "content": "Can you show me a simple example?" }  ],  "maxModelTokens": 4000,  "thresholdPercent": 0.6,  "minRecentMessages": 2,  "openaiModel": "gpt-4o-mini"}

Response:

json
{  "success": true,  "original_message_count": 6,  "compressed_message_count": 4,  "messages_removed": 2,  "summary_generated": true,  "compression_ratio": 0.67,  "compressed_messages": [    { "role": "system", "content": "You are a helpful assistant." },    {      "role": "system",      "content": "The user expressed interest in building a web scraper and requested help with Python. The assistant recommended using requests and BeautifulSoup libraries for Python web scraping."    },    {      "role": "assistant",      "content": "Great choice! For Python web scraping, I recommend using requests and BeautifulSoup..."    },    { "role": "user", "content": "Can you show me a simple example?" }  ]}

Message Format

Both tools expect messages in SlimContext format:

typescript
interface SlimContextMessage {  role: 'system' | 'user' | 'assistant' | 'tool' | 'human';  content: string;}

Error Handling

All tools return structured error responses:

json
{  "success": false,  "error": "Error message description",  "error_type": "SlimContextError" | "OpenAIError" | "UnknownError"}

Common error scenarios:

  • Missing OpenAI API key for summarization
  • Invalid message format
  • OpenAI API rate limits or errors
  • Invalid parameter values

Token Estimation

SlimContext uses a simple heuristic for token estimation: Math.ceil(content.length / 4) + 2. This provides a reasonable approximation for most use cases. For more accurate token counting, you would need to implement a custom token estimator in your client application.

Compression Strategies

Trimming Strategy

  • Preserves all system messages
  • Preserves the most recent N messages
  • Removes oldest non-system messages until under token threshold
  • Fast and deterministic
  • No external API dependencies

Summarization Strategy

  • Preserves all system messages
  • Preserves the most recent N messages
  • Summarizes middle portion of conversation using AI
  • Creates contextually rich summaries
  • Requires OpenAI API access

License

MIT

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

Related

Source: README.md at commit e269b85

Tools

0
SourceWeft has not started this package in its sandbox yet, so its tools are not known.

Version history

1
  1. v0.1.2LatestSep 16, 2026

Score

40% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts

    Declare a license in the repository or the registry entry.