Cognilens
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Spirrow-Cognilens
Context compression and summarization MCP server for optimizing AI context windows.
Overview
Cognilens = Cogni (認知/Cognition) + Lens (レンズ/Lens)
A magic lens that extracts only the essence from large amounts of information:
Saves Claude Code's context window
Compresses without losing important information
Optimal summarization strategies for different use cases
Smart model selection via Lexora API integration
Related MCP server: mcp-sophon
Installation
# Using pip
pip install spirrow-cognilens
# Using uvx (recommended for MCP)
uvx spirrow-cognilensQuick Start
Claude Desktop Configuration
Add to your claude_desktop_config.json:
{
"mcpServers": {
"cognilens": {
"command": "uvx",
"args": ["spirrow-cognilens"],
"env": {
"COGNILENS_LLM__PROVIDER": "openai",
"COGNILENS_LLM__API_KEY": "sk-your-api-key"
}
}
}
}Claude Code Configuration
Add to your Claude Code MCP settings:
{
"mcpServers": {
"cognilens": {
"command": "uvx",
"args": ["spirrow-cognilens"],
"env": {
"COGNILENS_LLM__PROVIDER": "openai",
"COGNILENS_LLM__API_KEY": "sk-your-api-key"
}
}
}
}MCP Tools
1. summarize
Summarize text with specified style.
Styles:
- concise: 80% compression - for overviews
- detailed: 50% compression - for implementation reference
- bullet: Structured bullet points
- code_aware: Preserves code structure, compresses explanations
- diff: Highlights changes between versions2. compress_context
Compress context for specific task execution.
Optimizes context window usage by keeping only task-relevant information.
3. extract_essence
Extract essential information from a document.
Identifies core concepts, key relationships, and critical specifications.
4. unify_summaries
Unify multiple documents into a single coherent summary.
Combines multiple sources, removes redundancy, and highlights conflicts.
5. summarize_diff
Summarize differences between two versions of text.
Highlights additions, deletions, and modifications.
6. progressive_compress
Apply progressive compression through multiple stages.
For very large documents, compress in stages to maintain quality.
Smart Model Selection
Cognilens integrates with Lexora's new APIs to automatically select the optimal model for each compression task.
Features
Automatic model selection: Chooses the best model based on task type
Capability-based matching: Maps compression strategies to model capabilities
4-level fallback: Classification API → Capability match → Heuristics → Default model
TTL-based caching: Model capabilities cached for performance (default: 5 minutes)
Strategy to Capability Mapping
Strategy | Capability | Use Case |
|
| Overview, task lists |
|
| Implementation reference, API specs |
|
| Structured key points |
|
| Code with explanations |
|
| Change analysis |
Enabling Smart Selection
llm:
provider: "openai"
base_url: "http://localhost:8110/v1"
model: "Qwen2.5-1.5B" # Fallback default
smart_selection:
enabled: true
cache_ttl_seconds: 300
classify_tasks: true
fallback_to_default: trueOr via environment variables:
COGNILENS_LLM__SMART_SELECTION__ENABLED=trueConfiguration
Environment Variables
Variable | Description | Default |
| LLM provider (mock/openai/lexora) |
|
| API key for LLM provider | - |
| Model to use |
|
| Custom API endpoint | - |
| Enable smart model selection |
|
| Capabilities cache TTL |
|
| Server port |
|
Config File
Create config.yaml in the working directory:
server:
name: "Spirrow-Cognilens"
port: 8003
llm:
provider: "openai"
base_url: "http://localhost:8110/v1"
model: "gpt-4o-mini"
timeout: 30
smart_selection:
enabled: false
cache_ttl_seconds: 300
classify_tasks: true
fallback_to_default: true
strategy_capability_map:
concise: "summarization"
detailed: "summarization"
bullet: "summarization"
code_aware: "code"
diff: "reasoning"
compression:
default_ratio: 0.3Development
# Clone the repository
git clone https://github.com/SpirrowGames/spirrow-cognilens.git
cd spirrow-cognilens
# Install with uv
uv sync
# Run tests
uv run pytest tests/ -v
# Run linting
uv run ruff check src/ tests/
# Run type checking
uv run mypy src/Architecture
┌─────────────────────────────────────────────────────────────┐
│ Cognilens MCP Server │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────────────────────────────────────────────┐ │
│ │ MCP Tools │ │
│ │ summarize | compress_context | extract_essence │ │
│ │ unify_summaries | summarize_diff | progressive │ │
│ └─────────────────────────────────────────────────────┘ │
│ │ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Compression Engine │ │
│ │ + ModelSelector (smart model selection) │ │
│ └─────────────────────────────────────────────────────┘ │
│ │ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Strategies: Concise | Detailed | Bullet | CodeAware │ │
│ │ Diff │ │
│ └─────────────────────────────────────────────────────┘ │
│ │ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ LLM Client: OpenAI | Lexora | Mock │ │
│ │ + Lexora APIs: /v1/models/capabilities │ │
│ │ /v1/classify-task │ │
│ └─────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘License
MIT License - see LICENSE for details.
Links
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Cross-tool persistent memory and context for AI assistants over MCP.
Stateless agentic tools over MCP: concept extraction, long-context, knowledge graph, planning.
Compress coding-agent context ~64%. Hosted Neural Keep MCP for Cursor/Claude/Codex.
Persistent personal memory for AI assistants — save, search, and recall across every MCP client.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA remote MCP server that compresses long text contexts, stores compact reusable summaries, and retrieves relevant context by title/tag/query, helping reduce token usage.-
- AlicenseNot gradedqualityBmaintenanceDeterministic context compression for MCP agents, reducing token usage via 11 tools for prompts, history, shell output, file deltas, and code navigation without ML or GPU.9MIT
- AlicenseNot gradedqualityDmaintenanceA task-aware context compression layer for Agent workflows, RAG pipelines, and AI Coding assistants, reducing noisy logs, retrieval chunks, and code context into high-signal LLM inputs via CLI, Python SDK, and MCP.22 PyPI324MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to cut token usage by locally pruning, encoding, and summarizing MCP tool responses, with lossless recovery of original data when needed.32 npm1Apache 2.0