Logo: SAGE-MCP

SAGE-MCP

Communautéit
david-strejc

🧙 SAGE-MCP: Simple AI Guidance Engine for Claude - Universal AI assistant with smart mode selection, conversation continuity, and intelligent file handling

Editeurdavid-strejc
Repositorysage-mcp
SproochPython
Forks
3
StÀren
11
Disponibel Tools
0
Transporttypstdio
Kategorien
Linken
  • Tools mat KI-Workflows verbannen

    SAGE-MCP bitt MCP-Funktiounen un, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • Disponibel Tools: 0

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopĂ©ieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an deem MCP-Client ze konfiguréieren, deen Dir am léifste benotzt.

  • Interessi vun der CommunautĂ©it um Open-Source-Projet

    Zuele vum verlinkte Repository – StĂ€ren: 11, Forks: 3.

🧙 SAGE-MCP: Simple AI Guidance Engine for Claude

Version License Claude Python

Universal AI assistant MCP server with intelligent mode selection, conversation continuity, and smart file handling

SAGE-MCP transforms Claude into a multi-talented development assistant that adapts to your needs. Whether you're debugging code, planning architecture, writing tests, or having a technical discussion, SAGE automatically selects the right approach and model for optimal results.

✹ Key Features

🎯 Intelligent Mode System

  • chat - Natural conversations with context awareness
  • analyze - Deep code analysis and pattern recognition
  • review - Comprehensive code reviews with actionable feedback
  • debug - Systematic debugging and root cause analysis
  • plan - Strategic project planning and architecture design
  • test - Test generation with coverage analysis
  • refactor - Code improvement and modernization
  • think - Deep reasoning with adjustable thinking depth

🔄 Conversation Continuity

  • Seamless multi-turn conversations across different modes
  • Automatic context preservation between tool calls
  • Smart file deduplication - never re-read the same files
  • Thread-based memory system for long-running tasks

đŸ€– Smart Model Selection

  • Auto mode - Intelligent model selection based on task complexity
  • Support for multiple providers: OpenAI, Anthropic, Google, OpenRouter
  • Model restrictions via environment variables for cost control
  • Thinking depth control: minimal (0.5%), low (8%), medium (33%), high (67%), max (100%)

📁 Intelligent File Handling

  • embedded - Full file content in context (default)
  • summary - Token-efficient summaries for large codebases
  • reference - File storage with ID references
  • output_file - Save output directly to disk (no context pollution)
  • Automatic directory expansion and smart deduplication
  • Security validation for all file operations

🌐 Web Search Integration

  • Real-time documentation lookup
  • Best practices and current standards
  • Framework and library research
  • Error and issue investigation

🎹 Mode Specializations

ModeTemperatureDescriptionBest For
chat0.5Natural conversations with balanced creativityQ&A, brainstorming, explanations
analyze0.2Focused precision for code analysisArchitecture review, pattern detection
review0.3Systematic evaluation with consistent standardsSecurity audits, best practices
debug0.1Deterministic analysis for troubleshootingError investigation, root cause analysis
plan0.4Strategic thinking for project planningArchitecture design, task breakdown
test0.2Accurate test generation with edge casesUnit tests, integration tests
refactor0.3Careful improvements preserving functionalityCode modernization, optimization
think0.7Creative problem solving with deep reasoningComplex algorithms, system design

🚀 Quick Start

Installation

bash
# Clone the repository
git clone https://github.com/david-strejc/sage-mcp
cd sage-mcp

# Install dependencies
pip install -r requirements.txt

# Configure your API keys
export OPENAI_API_KEY="your-key-here"
export ANTHROPIC_API_KEY="your-key-here"
export GOOGLE_API_KEY="your-key-here"
export OPENROUTER_API_KEY="your-key-here"

Claude Desktop Configuration

Add to your Claude Desktop MCP settings:

json
{
  "mcpServers": {
    "sage": {
      "command": "python",
      "args": ["/path/to/sage-mcp/server.py"],
      "env": {
        "OPENAI_API_KEY": "your-key",
        "ANTHROPIC_API_KEY": "your-key",
        "DEFAULT_MODEL": "gpt-4o",
        "DEFAULT_PROVIDER": "openai"
      }
    }
  }
}

📖 Usage Examples

Basic Chat

typescript
// In Claude:
Use sage tool to explain how async/await works in Python

Code Analysis with Files

typescript
// Analyze specific files
Use sage tool in analyze mode to review the architecture of ./src/api/

// With model selection
Use sage with model gpt-4o to analyze performance bottlenecks in server.py

Multi-turn Conversations

typescript
// First turn
Use sage to help me design a caching system

// Continue the conversation (Claude will auto-continue)
Now let's implement the LRU cache we discussed

// Files are automatically deduplicated across turns

Deep Thinking Mode

typescript
// For complex problems requiring deep reasoning
Use sage in think mode with thinking_mode="high" to solve this algorithmic challenge: [problem description]

Smart File Handling

typescript
// Token-efficient mode for large codebases
Use sage with file_handling_mode="summary" to review the entire project structure

// Reference mode for iterative work
Use sage with file_handling_mode="reference" to start refactoring the database layer

⚙ Configuration

Environment Variables

bash
# Provider Configuration
DEFAULT_PROVIDER=openai          # Default: auto
DEFAULT_MODEL=gpt-4o            # Default: auto
FALLBACK_MODEL=gpt-4o-mini      # Fallback for errors

# Model Restrictions (optional)
ALLOWED_MODELS=gpt-4o,gpt-4o-mini,claude-3-5-sonnet
DISALLOWED_MODELS=o1-preview,o1  # Expensive models to exclude

# Feature Flags
WEBSEARCH_ENABLED=true          # Enable web search
FILE_SECURITY_CHECK=true        # Validate file paths
AUTO_MODEL_SELECTION=true       # Smart model selection

# Token Limits
MAX_TOKENS_GPT4O=128000
MAX_TOKENS_CLAUDE=200000
MAX_THINKING_TOKENS_O1=100000

Mode-Specific Temperatures

Default temperatures optimized for each mode:

  • chat: 0.5 - Balanced creativity
  • analyze: 0.2 - Focused precision
  • review: 0.3 - Systematic evaluation
  • debug: 0.1 - Deterministic analysis
  • plan: 0.4 - Strategic thinking
  • test: 0.2 - Accurate test generation
  • refactor: 0.3 - Careful improvements
  • think: 0.7 - Creative problem solving

🔧 Advanced Features

Conversation Continuation

python
# Start conversation
response = sage(mode="chat", prompt="Let's design a web app")
# Returns: continuation_id: abc123

# Continue in same mode
sage(mode="chat", prompt="What database should we use?", continuation_id="abc123")

# Switch modes seamlessly  
sage(mode="analyze", prompt="Review our database schema", 
     files=["/db/schema.sql"], continuation_id="abc123")

Smart File Handling

python
# Multiple modes available
sage(mode="review",
     files=["/src", "/tests"],           # Auto-expands directories
     file_handling_mode="embedded",      # Full content (default)
     prompt="Security review")

sage(mode="analyze",
     files=["/large/codebase"],
     file_handling_mode="summary",       # Summaries only (saves tokens)
     prompt="Architecture overview")

sage(mode="debug",
     files=["/logs"],
     file_handling_mode="reference",     # Store with IDs
     prompt="Analyze error patterns")

Save Output to File

For large outputs that would pollute context, save directly to disk:

python
# Save analysis directly to file instead of returning in response
sage(mode="analyze",
     files=["/src"],
     prompt="Full codebase analysis",
     output_file="/tmp/analysis.md")
# Returns: "Output saved to /tmp/analysis.md (15.2KB)"

# Great for:
# - Large code reviews
# - Documentation generation
# - Analysis reports
# - Any output you want to process later

Features:

  • Creates parent directories automatically
  • Prevents accidental overwrites (file must not exist)
  • Blocks writes to system directories
  • Returns human-readable file size confirmation

Model Restrictions

bash
# Environment variables for cost control
OPENAI_ALLOWED_MODELS=o3-mini,gpt-4o-mini
GOOGLE_ALLOWED_MODELS=gemini-2.0-flash-exp,gemini-1.5-pro
BLOCKED_MODELS=gpt-4,claude-opus
DISABLED_MODEL_PATTERNS=expensive,legacy

# Auto mode requires model selection when restricted
DEFAULT_MODEL=auto  # Forces explicit model choice

Supported Models

ProviderModelsConfiguration
OpenAIgpt-4o, gpt-4o-mini, o1, o3-miniOPENAI_API_KEY
Anthropicclaude-3-5-sonnet, claude-3-5-haikuANTHROPIC_API_KEY
Googlegemini-2.0-flash-exp, gemini-1.5-proGOOGLE_API_KEY
OpenRouter100+ models from all providersOPENROUTER_API_KEY
Custom/Ollamallama3.2, mistral, codestralCUSTOM_API_URL

Complete Configuration Reference

VariableDescriptionExample
API Keys
OPENAI_API_KEYOpenAI API keysk-...
ANTHROPIC_API_KEYAnthropic Claude API keysk-ant-...
GEMINI_API_KEY / GOOGLE_API_KEYGoogle Gemini API keyAIzaSy...
OPENROUTER_API_KEYOpenRouter API keysk-or-...
XAI_API_KEYxAI (Grok) API keyxai-...
CUSTOM_API_URLCustom/Ollama API endpointhttp://localhost:11434
CUSTOM_API_KEYCustom API key (if required)custom-key
Model Selection
DEFAULT_MODELDefault model (auto for selection)o3, gpt-5, auto
Model Restrictions
OPENAI_ALLOWED_MODELSAllowed OpenAI modelso3,gpt-5
GOOGLE_ALLOWED_MODELSAllowed Google modelsgemini-2.5-pro,gemini-2.5-flash
ANTHROPIC_ALLOWED_MODELSAllowed Anthropic modelsclaude-3-5-sonnet
BLOCKED_MODELSBlocked models (any provider)gpt-4,o3-mini
DISABLED_MODEL_PATTERNSDisable by patternanthropic,claude,mini
Limits & Performance
MAX_FILE_SIZEMaximum file size in bytes5242880 (5MB)
MCP_PROMPT_SIZE_LIMITMCP transport limit50000
MAX_CONVERSATION_TURNSMax turns per conversation20
CONVERSATION_TIMEOUT_HOURSConversation timeout3
Memory & Storage
REDIS_URLRedis connection for memoryredis://localhost:6379/0
REDIS_DBRedis database number0
Temperature Overrides
TEMPERATURE_CHATChat mode temperature0.7
TEMPERATURE_ANALYZEAnalyze mode temperature0.3
TEMPERATURE_DEBUGDebug mode temperature0.2
TEMPERATURE_PLANPlan mode temperature0.4
TEMPERATURE_TESTTest mode temperature0.3
TEMPERATURE_REFACTORRefactor mode temperature0.4
TEMPERATURE_REVIEWReview mode temperature0.5
TEMPERATURE_THINKThink mode temperature0.8

đŸ—ïž Architecture

sage-mcp/
├── server.py           # FastMCP server entry point
├── config.py           # Configuration management
├── tools/
│   └── sage.py        # Universal SAGE tool
├── modes/             # Specialized AI modes
│   ├── base.py        # Base mode handler
│   ├── chat.py        # Conversational mode
│   ├── analyze.py     # Code analysis mode
│   ├── debug.py       # Debugging mode
│   └── ...
├── providers/         # AI provider integrations
│   ├── openai.py
│   ├── anthropic.py
│   ├── gemini.py
│   └── openrouter.py
├── models/           # Model management
│   ├── manager.py    # Intelligent model selection
│   └── config.yaml   # Model capabilities
└── utils/            # Utilities
    ├── files.py      # File handling
    ├── memory.py     # Conversation memory
    ├── models.py     # Model restrictions
    └── security.py   # Security validation

đŸ§Ș Advanced Features

Model Restrictions

Control which models can be used to manage costs:

bash
# Allow only specific models
export ALLOWED_MODELS="gpt-4o-mini,claude-3-haiku"

# Exclude expensive models
export DISALLOWED_MODELS="o1-preview,claude-3-opus"

Conversation Memory

SAGE maintains conversation context across tool calls:

python
# Automatically continues conversations
# Previous context and files are preserved
# Smart deduplication prevents re-reading

Custom Providers

Add custom AI providers by implementing the base provider interface:

python
class CustomProvider(BaseProvider):
    async def generate(self, messages, **kwargs):
        # Your implementation
        pass

đŸ€ Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

bash
# Install dev dependencies
pip install -r requirements-dev.txt

# Run tests
pytest

# Format code
black .
ruff check .

📄 License

MIT License - see LICENSE for details.

🙏 Acknowledgments

🔗 Links


SAGE-MCP - Your intelligent AI assistant that adapts to how you work 🧙✹

Installatioun

TypingMind
Viraussetzungen:

Node.js 18+

{
  "mcpServers": {
    "david-strejc-sage-mcp": {
      "command": "",
      "args": []
    }
  }
}

SAGE-MCP MCP mat verschiddene KI-Modeller benotzen

TypingMind verbĂ«nnt MCP-Tools um Niveau vum AarbechtsberĂ€ich. Soubal SAGE-MCP verbonnen ass, kĂ«nnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. DĂ«s MCP-Integratioun leeft lokal iwwer den TypingMind-MCP-Connector op Ärem Apparat.

Ariichtungsuleedung, fir de lokale Connector ze benotzen

Benotzt dĂ«s Optioun, wann den MCP-Server ZougrĂ«ff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „DĂ«sen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector: D'Optioun „DĂ«sen Apparat“ ass ausgewielt
2

De Connector-Befeel ausféieren

Wielt „DĂ«sen Apparat“, kopĂ©iert de Befeel aus TypingMind a fĂ©iert en am Terminal aus. Loosst de Prozess lafen, wĂ€rend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Setzt de kopéierte Befeel an a féiert en aus.
  4. BestÀtegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wÀrend Dir MCP-Tools benotzt.
3

SAGE-MCP als Server derbÀisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren Ă€nneren“ a setzt d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren Ă€nneren“.
  3. Setzt d'MCP-Serverkonfiguratioun fir SAGE-MCP an.
  4. SpÀichert d'Serverlëscht.
  5. Aktualiséiert d'SÀit, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem KnĂ€ppchen „Serveren Ă€nneren“
{
  "mcpServers": {
    "david-strejc-sage-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "sage-mcp"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

SpĂ€ichert d'ServerlĂ«scht, maacht „Plugins“ op an aktivĂ©iert d'MCP-Tools vun der Integratioun SAGE-MCP. Wielt dann e belibegen Ă«nnerstĂ«tzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'SĂ€it „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vun der Integratioun SAGE-MCP.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierten MCP-Tools an engem ausgewielte KI-Modell
Kënnt Dir mir mat SAGE-MCP bei dëser Aufgab hëllefen?
SAGE-MCP
Jo. Ech hunn et gelies.
Dat hunn ech mat SAGE-MCP fonnt.

Heefeg gestallte Froen

Fir wat gëtt den MCP-Server SAGE-MCP benotzt?

SAGE-MCP ass en MCP-Server, deen et kompatibele KI-Clienten erlaabt, op extern Tools a Kontextinformatioune zouzegrĂ€ifen. An TypingMind kĂ«nnt Dir dĂ«sen MCP-Server eemol derbĂ€isetzen a seng Tools an Ärem KI-AarbechtsberĂ€ich zur VerfĂŒgung stellen.

Kann ech SAGE-MCP MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum AarbechtsberÀich. Sou kënnt Dir SAGE-MCP mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni den MCP-Server fir all Modell separat anzeriichten.

Firwat SAGE-MCP MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte BenotzeruewerflĂ€che fir LLM-Chat, well et mĂ©i KI-Modeller, Prompts, Plugins, KI-Agenten, API-SchlĂ«sselen a MCP-Tools an engem AarbechtsberĂ€ich zesummebrĂ©ngt. Wann SAGE-MCP verbonnen ass, kĂ«nnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a glĂ€ichzĂ€iteg Ären Aarbechtsoflaf beim Chatten an TypingMind organisĂ©ieren.

Wéi verbannen ech SAGE-MCP MCP mat TypingMind?

SAGE-MCP leeft iwwer de lokale MCP-Connector vun TypingMind. Dat eegent sech am beschten, wann den MCP-Server ZougrĂ«ff op lokal Fichieren, Desktop-Apps, Kommandozeilen-Tools oder privat Ressourcen op Ärem Computer brauch.

WĂ©i eng Tools stellt SAGE-MCP MCP an TypingMind zur VerfĂŒgung?

SAGE-MCP stellt MCP-Funktioune zur VerfĂŒgung, dĂ©i Dir op der Plugins-SĂ€it vun TypingMind aktivĂ©iere kĂ«nnt, fir se am Chat ze benotzen oder KI-Agente zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir SAGE-MCP MCP ze benotzen?

Nee. TypingMind ass nom Local-first-Prinzip opgebaut a lĂ©isst Iech d'Kontroll iwwer Är Modellubidder, API-SchlĂ«sselen, Prompts a MCP-Konfiguratioun. Wann SAGE-MCP eng AuthentifizĂ©ierung verlaangt, setzt dĂ©i nĂ©ideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir deen MCP-Server derbĂ€i, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

Alleguer weisen

Elo Ären eegene KI-AarbechtsberĂ€ich ariichten

AbonnĂ©iert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukĂŒnfteg GewĂ«nnspiller informĂ©iert ze ginn 👇