Context Optimizer MCP Server
Provides context optimization tools specifically designed for GitHub Copilot, enabling targeted information extraction from files and command outputs
Integrates with Google Gemini API as an LLM provider for context optimization, file analysis, and intelligent extraction of relevant information
Supports OpenAI models as an LLM provider for context optimization tasks including file analysis, terminal output processing, and research capabilities
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Context Optimizer MCP Server runAndExtract: find all TypeScript errors in the current directory"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Context Optimizer MCP Server
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.
Related MCP server: Semantic Cache MCP
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-server2. 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 previousrunAndExtractcalls 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:
Topic | Location | Description |
Architecture |
| System design and component overview |
Tools Reference |
| Complete tool documentation and examples |
Usage Guide |
| Complete setup and configuration |
VS Code Setup |
| VS Code specific configuration |
Troubleshooting |
| Common issues and solutions |
API Keys |
| API key management |
Testing |
| Testing framework and procedures |
Changelog |
| Version history |
Contributing |
| Development guidelines |
Security |
| Security policy |
Code of Conduct |
| Community guidelines |
Quick Links
Get Started: See
docs/guides/usage.mdfor complete setup instructionsTools Reference: Check
docs/tools.mdfor detailed tool documentationTroubleshooting: Check
docs/guides/troubleshooting.mdfor common issuesVS Code Setup: Follow
docs/guides/vs-code-setup.mdfor 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:watchManual 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
VS Code Copilot Context Optimizer – Original VS Code extension (companion project)
Available Tools
5 toolsaskAboutFileA
Extract specific information from files without reading their entire contents into chat context. Works with text files, code files, images, PDFs, and more.
Inputs: filePath (required), question (required).
askFollowUpA
Ask follow-up questions about the previous terminal command execution without re-running the command. Only available after using runAndExtract tool.
Inputs: question (required).
deepResearchB
Conduct comprehensive, in-depth research using Exa.ai's exhaustive analysis capabilities for critical decision-making and complex architectural planning.
Inputs: topic (required).
researchTopicB
Conduct quick, focused web research on software development topics using Exa.ai's powerful research capabilities for current information and practical implementation guidance.
Inputs: topic (required).
runAndExtractB
Execute terminal commands and intelligently extract specific information from their output. Supports cross-platform command execution with security controls.
Inputs: terminalCommand (required), extractionPrompt (required), workingDirectory (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool targets a distinct source and action: file analysis, quick web research, deep web research, terminal command follow-up, and terminal execution with extraction. While researchTopic and deepResearch are related, their descriptions clearly separate quick versus exhaustive research, preventing mis-selection.
Names are readable and mostly camelCase, but follow different patterns: askAboutFile and askFollowUp use 'ask' + phrase, researchTopic is verb+noun, deepResearch is an adjective-noun phrase, and runAndExtract is verb+verb. The mixed conventions are still predictable in context but lack a consistent verb_noun structure.
Five tools is well-scoped for a context optimization server. Each tool fills a clear niche—file extraction, quick research, deep research, command execution extraction, and follow-up—without redundancy or clutter.
The surface covers the main context-gathering needs: files, web research, and terminal output. A minor gap is that askFollowUp only attaches to runAndExtract, leaving no follow-up mechanism for askAboutFile or research results, but agents can still work around this.
Maintenance
Related MCP Connectors
Provide your AI coding tools with token-efficient access to up-to-date technical documentation for…
The context platform for AI agents: code search, team decisions, and grounded project context.
Cuts coding agent token burn up to 72% continuously via contradiction-free memory & verification.
Shared memory and context across ChatGPT, Claude, Claude Code, Codex, Cursor and 20+ AI tools
Related MCP Servers
- AlicenseAqualityCmaintenanceProvides intelligent code context and analysis through semantic compression, AST parsing, and multi-language support. Offers 60-80% token reduction while enabling AI assistants to understand codebases through local analysis, OpenAI-enhanced insights, and GitHub repository integration.6229 npm3MIT
- AlicenseAqualityBmaintenanceMCP file cache for AI coding agents. Re-reading an unchanged file costs ~40 tokens instead of the whole file; a changed file comes back as a diff. Adds grep, BM25 search and glob over cached files, atomic edits with dry_run, and token-budgeted batch reads. One local daemon serves every client. No API keys, no GPU. Works with Claude Code, Cursor, VS Code, Codex and OpenCode.1479 PyPI3MIT

Code Scalpelofficial
AlicenseNot gradedqualityDmaintenanceEnables AI assistants to surgically extract and analyze code, reducing token usage and costs by up to 200x compared to reading entire files.20MIT- AlicenseNot gradedqualityBmaintenanceReduces token consumption for AI coding agents by 50-70% through intelligent code context filtering, Git delta tracking, and local SQLite/Tree-sitter indexing.167 npmMIT