context-slim

context-slim

Provides an MCP server for AI coding agents to fetch AST-slimmed source files that keep critical logic like try/catch, auth, and Eloquent relations, cutting context tokens by 50%+.

Category
Visit Server

README

ContextSlim

Save 50%+ AI context tokens without losing critical code semantics.

Code: github.com/lilite572-cyber/context-slim · install: @idmxgne/context-slim (npm account idmxgne). Not Jagganu’s context-slim (CLI output trimmer).

Cursor, Claude, and other coding agents re-read whole files on every turn. Most of that budget is JSDoc, unused imports, and DTO mappers. ContextSlim parses JS/TS (Babel) and PHP (php-parser), hollows the noise, and keeps try/catch, auth methods, env() / process.env, and markers like FIXME / SECURITY / В ПРОД НЕ ГНАТЬ.

Before / after

Measured on the real-world billing controller in tests/fixtures/real_world_controller.ts (--signatures-only):

Tokens What you keep
Before 3,522 comments, mappers, unused imports, every method body
After 1,408 signatures + critical bodies + protected comments
Savings 60% (10 labels kept) try/catch, authorize / login, FIXME, В ПРОД НЕ ГНАТЬ

CLI stats use gpt-tokenizer (o200k_base, GPT-4o / GPT-5 family) and print to stderr. Slim source goes to stdout.

npx -y --package=@idmxgne/context-slim context-slim .
# Исходный размер: 3,522 токенов -> Сжатый: 1,408 токенов. Экономия: 60% ...

The binary is context-slim, not @idmxgne/context-slim. Scoped npx @idmxgne/context-slim . fails with command not found.

Quick start

npx -y --package=@idmxgne/context-slim context-slim .
npx -y --package=@idmxgne/context-slim context-slim ./src --signatures-only
npx -y --package=@idmxgne/context-slim context-slim ./src --out slim.txt
npx -y --package=@idmxgne/context-slim context-slim-mcp

From a clone:

npm i && npm run build
node dist/cli.js ./src

MCP server (Cursor, Windsurf, Claude Code)

Bin: context-slim-mcpdist/mcp.js. Official @modelcontextprotocol/sdk Server + StdioServerTransport. Do not write logs to stdout.

Prompt use-slim-context:

Always prioritize using read_slim_file tool when reading source code files to optimize context window.

Tools:

Tool Args Result
read_slim_file path (string), signaturesOnly (boolean, default true) compressed source
get_slim_stats none last run: tokens before / after, % saved, protected label count

Cursor

Merge into ~/.cursor/mcp.json (ready-made copy: examples/cursor-mcp.json):

{
  "mcpServers": {
    "context-slim": {
      "command": "node",
      "args": ["/ABSOLUTE/PATH/TO/context-slim/dist/mcp.js"]
    }
  }
}

After npm publish:

{
  "mcpServers": {
    "context-slim": {
      "command": "npx",
      "args": ["-y", "--package=@idmxgne/context-slim", "context-slim-mcp"]
    }
  }
}

Restart Cursor and ask the agent to read_slim_file on a fat controller.

Windsurf

Same mcpServers block in Windsurf's MCP config (~/.codeium/windsurf/mcp_config.json, or the MCP panel in settings). Point command at node + dist/mcp.js, or at npx as above.

Claude Code / Claude Desktop

Claude Desktop — merge examples/claude_desktop_config.json into claude_desktop_config.json:

{
  "mcpServers": {
    "context-slim": {
      "command": "node",
      "args": ["/ABSOLUTE/PATH/TO/context-slim/dist/mcp.js"]
    }
  }
}

Claude Code:

claude mcp add context-slim -- node /ABSOLUTE/PATH/TO/context-slim/dist/mcp.js

Safe labels (.contextslimrc + isCriticalNode)

A node is never hollowed when isCriticalNode says so:

  • comments matching CRITICAL, FIXME, TODO, SECURITY, DONT TOUCH, В ПРОД НЕ ГНАТЬ, @keep
  • try / catch
  • methods whose names look like auth (authorize, login, jwt, csrf, …)
  • env(), getenv(), process.env
  • PHP/Laravel: $this->hasMany / $this->belongsTo (and other Eloquent relations) and scope* methods

Repo: https://github.com/lilite572-cyber/context-slim

Put extra phrases in .contextslimrc at the project root:

{
  "keep_patterns": ["HACK", "LEGACY"]
}

entry_patterns (defaults: index / cli / main / app / server) keep ordinary function bodies even without --signatures-only. Dependency files are hollowed; pass --signatures-only (or MCP signaturesOnly: true) to hollow everything that is not critical.

Install / publish

npm i
npm test
npm run build

Bins: context-slim./dist/cli.js, context-slim-mcp./dist/mcp.js. npm: @idmxgne/context-slim. GitHub: lilite572-cyber/context-slim. License: MIT.

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured