Context Optimizer

Context Optimizer

malaksedarous

Helps AI coding assistants extract only relevant information from files, terminal outputs, and web searches instead of consuming entire context with unnecessary data.

Provides targeted file content extraction, secure terminal command execution with intelligent output analysis, and web research capabilities while maintaining session state for follow-up interactions and enforcing security boundaries through path validation and command filtering.

53298 views6Local (stdio)

What it does

  • Extract targeted content from large files
  • Execute terminal commands with filtered output analysis
  • Perform focused web research and content extraction
  • Maintain session state across interactions
  • Filter command outputs to prevent context overflow

Best for

Developers using AI assistants like Copilot or CursorPreventing context limit issues in long coding sessionsOptimizing AI assistant performance with large codebases
Prevents AI context overflowBuilt-in security filteringSession state management

About Context Optimizer

Context Optimizer is a community-built MCP server published by malaksedarous that provides AI assistants with tools and capabilities via the Model Context Protocol. Context Optimizer offers web keyword analysis, website keyword analysis, and secure content extraction to help you find It is categorized under productivity, developer tools.

How to install

You can install Context Optimizer in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.

License

Context Optimizer is released under the MIT license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.

Context Optimizer MCP Server

npm version license node tests

A Model Context Protocol (MCP) server that provides context optimization tools for AI coding assistants including GitHub Copilot, Cursor AI, Claude Desktop, and other MCP-compatible assistants enabling them to extract targeted information rather than processing large terminal outputs and files wasting their context.

This MCP server is the evolution of the VS Code Copilot Context Optimizer extension, but with compatibility across MCP-supporting applications.

🎯 The Problem It Solves

Have you ever experienced this with your AI coding assistant (like Copilot, Claude Code, or Cursor)?

  • πŸ”„ Your assistant keeps compacting/summarizing conversations and losing a bit of the context in the process.
  • πŸ–₯️ Terminal outputs flood the context with hundreds of lines when the assistant only needs key information.
  • πŸ“„ Large files overwhelm the context when the assistant just needs to check one specific thing.
  • ⚠️ "Context limit reached" messages interrupting your workflow.
  • 🧠 Your assistant "forgets" earlier parts of your conversation due to context overflow.
  • 😫 The reasoning quality drops when you have a longer conversation.

The Root Cause: When your assistant:

  • Reads long logs during builds, tests, lints, etc. after executing a terminal command.
  • Reads a large file (or multiple) in full just to answer a question when it doesn't need the whole code.
  • Reads multiple web pages from the web to search a topic to learn how to do something.
  • Or just during a long conversation.

The assistant will either:

  • Start compacting, summarizing or truncating the conversation history.
  • Drop the quality of reasoning.
  • Lose track of earlier context and decisions.
  • Become less helpful as it loses focus.

The Solution:

This server provides any MCP-compatible assistant with specialized tools that extract only the specific information you need, keeping your chat context clean and focused on productive problem-solving rather than data management.

Features

  • πŸ” File Analysis Tool (askAboutFile) - Extract specific information from files without loading entire contents
  • πŸ–₯️ Terminal Execution Tool (runAndExtract) - Execute commands and extract relevant information using LLM analysis
  • ❓ Follow-up Questions Tool (askFollowUp) - Continue conversations about previous terminal executions
  • πŸ”¬ Research Tools (researchTopic, deepResearch) - Conduct web research using Exa.ai's API
  • πŸ”’ Security Controls - Path validation, command filtering, and session management
  • πŸ”§ Multi-LLM Support - Works with Google Gemini, Claude (Anthropic), and OpenAI
  • βš™οΈ Environment Variable Configuration - API key management through system environment variables
  • πŸ—οΈ Simple Configuration - Environment variables only, no config files to manage
  • πŸ§ͺ Comprehensive Testing - Unit tests, integration tests, and security validation

Quick Start

1. Install globally:

npm install -g context-optimizer-mcp-server

2. Set environment variables (see docs/guides/usage.md for OS-specific instructions):

export CONTEXT_OPT_LLM_PROVIDER="gemini"
export CONTEXT_OPT_GEMINI_KEY="your-gemini-api-key"
export CONTEXT_OPT_EXA_KEY="your-exa-api-key"
export CONTEXT_OPT_ALLOWED_PATHS="/path/to/your/projects"

3. Add to your MCP client configuration:

like "mcpServers" in claude_desktop_config.json (Claude Desktop) or "servers" in mcp.json (VS Code).

"context-optimizer": {
  "command": "context-optimizer-mcp"
}

For complete setup instructions including OS-specific environment variable configuration and AI assistant setup, see docs/guides/usage.md.

Available Tools

  • askAboutFile - Extract specific information from files without loading entire contents into chat context. Perfect for checking if files contain specific functions, extracting import/export statements, or understanding file purpose without reading the full content.

  • runAndExtract - Execute terminal commands and intelligently extract relevant information using LLM analysis. Supports non-interactive commands with security validation, timeouts, and session management for follow-up questions.

  • askFollowUp - Continue conversations about previous terminal executions without re-running commands. Access complete context from previous runAndExtract calls including full command output and execution details.

  • researchTopic - Conduct quick, focused web research on software development topics using Exa.ai's research capabilities. Get current best practices, implementation guidance, and up-to-date information on evolving technologies.

  • deepResearch - Comprehensive research and analysis using Exa.ai's exhaustive capabilities for critical decision-making and complex architectural planning. Ideal for strategic technology decisions, architecture planning, and long-term roadmap development.

For detailed tool documentation and examples, see docs/tools.md and docs/guides/usage.md.

Documentation

All documentation is organized under the docs/ directory:

TopicLocationDescription
Architecturedocs/architecture.mdSystem design and component overview
Tools Referencedocs/tools.mdComplete tool documentation and examples
Usage Guidedocs/guides/usage.mdComplete setup and configuration
VS Code Setupdocs/guides/vs-code-setup.mdVS Code specific configuration
Troubleshootingdocs/guides/troubleshooting.mdCommon issues and solutions
API Keysdocs/reference/api-keys.mdAPI key management
Testingdocs/reference/testing.mdTesting framework and procedures
Changelogdocs/reference/changelog.mdVersion history
Contributingdocs/reference/contributing.mdDevelopment guidelines
Securitydocs/reference/security.mdSecurity policy
Code of Conductdocs/reference/code-of-conduct.mdCommunity guidelines

Quick Links

  • Get Started: See docs/guides/usage.md for complete setup instructions
  • Tools Reference: Check docs/tools.md for detailed tool documentation
  • Troubleshooting: Check docs/guides/troubleshooting.md for common issues
  • VS Code Setup: Follow docs/guides/vs-code-setup.md for VS Code configuration

Testing

# Run all tests (skips LLM integration tests without API keys)
npm test

# Run tests with API keys for full integration testing
# Set environment variables first:
export CONTEXT_OPT_LLM_PROVIDER="gemini"
export CONTEXT_OPT_GEMINI_KEY="your-gemini-key"
export CONTEXT_OPT_EXA_KEY="your-exa-key"
npm test  # Now runs all tests including LLM integration

# Run in watch mode
npm run test:watch

Manual Testing

For comprehensive end-to-end testing with an AI assistant, see the Manual Testing Setup Guide. This provides a workflow-based testing protocol that validates all tools through realistic scenarios.

For detailed testing setup, see docs/reference/testing.md.

Contributing

Contributions are welcome! Please read docs/reference/contributing.md for guidelines on development workflow, coding standards, testing, and submitting pull requests.

Community

  • Code of Conduct: See docs/reference/code-of-conduct.md
  • Security Reports: Follow docs/reference/security.md for responsible disclosure
  • Issues: Use GitHub Issues for bugs & feature requests
  • Pull Requests: Ensure tests pass and docs are updated
  • Discussions: (If enabled) Use for open-ended questions/ideas

License

MIT License - see LICENSE file for details.

Related Projects

Alternatives

Related Skills

Browse all skills
teams-channel-post-writer

Creates educational Teams channel posts for internal knowledge sharing about Claude Code features, tools, and best practices. Applies when writing posts, announcements, or documentation to teach colleagues effective Claude Code usage, announce new features, share productivity tips, or document lessons learned. Provides templates, writing guidelines, and structured approaches emphasizing concrete examples, underlying principles, and connections to best practices like context engineering. Activates for content involving Teams posts, channel announcements, feature documentation, or tip sharing.

4
chief-architect

PERSONAL APP ARCHITECT - Strategic development orchestrator for personal productivity applications. Analyzes project context, makes architectural decisions for single-developer projects, delegates to specialized skills, and ensures alignment between user experience goals and technical implementation. Optimized for personal apps targeting 10-100 users.

1
mcp-builder

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

103
ui-ux-expert-skill

Technical workflow for implementing accessible React user interfaces with shadcn/ui, Tailwind CSS, and TanStack Query. Includes 6-phase process with mandatory Style Guide compliance, Context7 best practices consultation, Chrome DevTools validation, and WCAG 2.1 AA accessibility standards. Use after Test Agent, Implementer, and Supabase agents complete their work.

66
context-optimizer

Advanced context management with auto-compaction and dynamic context optimization for DeepSeek's 64k context window. Features intelligent compaction (merging, summarizing, extracting), query-aware relevance scoring, and hierarchical memory system with context archive. Logs optimization events to chat.

29
liquid-glass-developer

Context-aware routing to iOS 26 Liquid Glass implementation patterns. Use when working with glass effects, GlassEffectContainer, morphing transitions, or iOS 26 visual effects.

21