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 "Install 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 ServerrunAndExtract: 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: Ambiance MCP Server
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.
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Full absolute path to the file to analyze (e.g., "C:\Users\username\project\src\file.ts", "/home/user/project/docs/README.md") | |
| question | Yes | Specific question about the file content (e.g., "Does this file export a validateEmail function?", "What is the main purpose described in this spec?", "Extract all import statements") |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided. Description conveys read-only nature but lacks details on error handling for unsupported files, authorization needs, or rate limits.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Single sentence that front-loads the core purpose and covers key aspects without redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Basic but sufficient given the tool's simplicity. Missing details on return format or error cases, but not critical for a straightforward extraction tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% with clear descriptions. The tool description adds minimal extra meaning beyond listing supported file types.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it extracts specific information from files without loading entire content, lists supported file types, and distinguishes from reading full files.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies use when needing specific info from files without full context, but does not explicitly state when not to use or mention alternatives among siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
askFollowUpA
Ask follow-up questions about the previous terminal command execution without re-running the command. Only available after using runAndExtract tool.
| Name | Required | Description | Default |
|---|---|---|---|
| question | Yes | Follow-up question about the previous terminal command execution and its output |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description bears full responsibility. It mentions the prerequisite (after runAndExtract) but does not disclose what happens if called without that prerequisite or any other behavioral traits like error handling or idempotency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise with two sentences, no redundant words. It front-loads the core purpose and adds a critical usage constraint in the second sentence.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity (one parameter, no output schema, no annotations), the description is mostly adequate. However, it lacks information about the return value or error behavior, which could hinder an AI agent understanding edge cases.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has 100% coverage with one required parameter 'question' described as 'Follow-up question about the previous terminal command execution and its output.' The description adds meaningful context beyond the schema by specifying the scope of the question.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Ask follow-up questions about the previous terminal command execution without re-running the command.' It specifies the verb (ask), resource (previous terminal command execution), and distinguishes it from re-running the command.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly states when to use the tool: 'Only available after using runAndExtract tool.' It also clarifies what it avoids: 'without re-running the command.' This provides good usage context, though it does not explicitly mention alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
deepResearchB
Conduct comprehensive, in-depth research using Exa.ai's exhaustive analysis capabilities for critical decision-making and complex architectural planning.
| Name | Required | Description | Default |
|---|---|---|---|
| topic | Yes | The research topic or problem you want to investigate comprehensively. Be as detailed as possible about what you want to learn, including technical requirements, architectural considerations, performance needs, security concerns, or strategic implications you want analyzed in depth. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It does not mention any behavioral traits such as rate limits, costs, internal processes, or side effects. For a research tool, the description lacks important context about what happens during the research or how results are returned.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence that efficiently conveys the tool's purpose and target scenarios. No unnecessary words or repetition, earning high marks for conciseness.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with one required parameter and no output schema or annotations, the description provides adequate context about purpose but lacks behavioral details. It is sufficiently complete for a simple tool, but could be improved with transparency about the research process or limitations.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema's parameter 'topic' has a detailed description that already covers semantic guidance, including recommendations for technical requirements, architectural considerations, etc. The tool description does not add further information about parameters beyond what the schema provides, so the baseline score of 3 is appropriate given 100% schema coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states that the tool conducts comprehensive, in-depth research using Exa.ai for critical decision-making and complex architectural planning. It specifies the verb 'research' and the resource 'Exa.ai's exhaustive analysis capabilities,' but does not explicitly differentiate it from the sibling tool 'researchTopic', which likely has a similar purpose.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for high-stakes situations like critical decision-making and architectural planning, but it does not provide explicit when-to-use or when-not-to-use guidance, nor does it mention alternatives among sibling tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
researchTopicB
Conduct quick, focused web research on software development topics using Exa.ai's powerful research capabilities for current information and practical implementation guidance.
| Name | Required | Description | Default |
|---|---|---|---|
| topic | Yes | The research topic or problem you want to investigate. Be as detailed as possible about what you want to learn, any specific aspects to focus on, timeframes, geographical scope, or particular angles of interest. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden but only mentions using Exa.ai's capabilities and returning 'current information and practical implementation guidance'. It does not disclose behavioral traits like rate limits, result format, or any constraints.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence of 20 words, concise and front-loaded with the core purpose. It avoids fluff but could include usage guidance without much increase in length.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple tool with one parameter and no output schema, the description is minimally adequate. However, it lacks differentiation from sibling tools and does not address behavioral aspects, leaving gaps for an AI agent to infer.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the parameter is already well-documented in the schema. The tool description adds no additional meaning or context beyond what the schema provides.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb ('conduct'), resource ('web research using Exa.ai'), and scope ('software development topics'). It effectively distinguishes from sibling tools like deepResearch by specifying 'quick, focused' research.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance on when to use this tool versus alternatives like deepResearch or askFollowUp. The description does not specify when not to use it or provide context for choosing among siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
runAndExtractB
Execute terminal commands and intelligently extract specific information from their output. Supports cross-platform command execution with security controls.
| Name | Required | Description | Default |
|---|---|---|---|
| terminalCommand | Yes | Shell command to execute. Must be non-interactive (no user input prompts). Navigation commands (cd, pushd, etc.) are not allowed - use workingDirectory instead. | |
| extractionPrompt | Yes | Natural language description of what information to extract from the command output. Examples: "Show me the raw output", "Summarize the results", "Extract all error messages", "Find version numbers", "List all files", "Did the command succeed?", "Are there any warnings?" | |
| workingDirectory | Yes | Full absolute path where command should be executed (e.g., "C:\Users\username\project", "/home/user/project"). Must be within configured security boundaries. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, so description must fully disclose behavior. Mentions security controls and extraction, but doesn't explain output format, error handling, or limitations of the extraction process.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, no redundant information, purpose is front-loaded and clear.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Three required parameters, no output schema, no annotations. Description does not explain what the tool returns or how extraction results are structured, leaving significant gaps for the agent.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% with descriptions for each parameter. The description adds little beyond restating purpose; no new parameter meaning.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description clearly states specific verb 'Execute terminal commands' and resource 'output extraction', distinguishing it from sibling tools which are about asking questions or research.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Implies usage through security controls and cross-platform support, but lacks explicit when-to-use, when-not-to-use, or alternative tool references.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
Most tools have distinct purposes, but 'deepResearch' and 'researchTopic' both involve web research using Exa.ai, which could cause confusion about when to use each. The other tools (askAboutFile, askFollowUp, runAndExtract) are clearly differentiated by their specific contexts and functions.
The naming is mixed with no consistent pattern: 'askAboutFile' and 'askFollowUp' use a verb-object style, 'deepResearch' and 'researchTopic' use adjective-noun, and 'runAndExtract' uses verb-and-verb. While readable, the lack of a unified convention reduces predictability across the tool set.
With 5 tools, the count is well-scoped for a context optimization server. Each tool appears to serve a specific, non-trivial function, and the number is manageable without being overly sparse or bloated, fitting typical expectations for such a domain.
The tool set covers key areas like file interrogation, terminal command execution with follow-ups, and web research, which aligns well with a context optimization purpose. A minor gap is the lack of tools for managing or optimizing chat context directly, but the existing tools support core workflows effectively.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Provide your AI coding tools with token-efficient access to up-to-date technical documentation forβ¦
SaaS intelligence for AI agents. 5 unified tools cover 1,000+ services with 91-96% token savings.
Project memory, semantic code search, and grounded agent context.
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Related MCP Servers
- AlicenseBqualityDmaintenanceExtracts minimal, relevant code context from multiple programming languages while analyzing diffs and optimizing imports to reduce token usage for AI assistants. Supports TypeScript/JavaScript, Python, Go, and Rust with token-aware caching.7261MIT
- AlicenseAqualityDmaintenanceProvides 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.6223MIT
- AlicenseAqualityBmaintenanceReduces token consumption by over 80% through intelligent file caching, returning only diffs for modified files and suppressing unchanged content. It features a suite of 12 tools for semantic search, batch reading, and efficient file editing to optimize LLM interactions with large codebases.132MIT

Code Scalpelofficial
AlicenseNot gradedqualityCmaintenanceEnables AI assistants to surgically extract and analyze code, reducing token usage and costs by up to 200x compared to reading entire files.17MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/malaksedarous/context-optimizer-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server