شعار Enhanced Grok Search MCP Server

Enhanced Grok Search MCP Server

المجتمع
stat-guy

Enhanced Grok Search MCP Server with comprehensive analysis capabilities - A robust MCP server providing web search, news search, and Twitter/X search through xAI's Grok API with rich analysis features including timelines, direct quotes, and multiple perspectives.

الناشرstat-guy
المستودعgrok-search-mcp
اللغةJavaScript
التفريعات
3
النجوم
19
الأدوات المتاحة
5
نوع نقل البياناتstdio
الفئات
الترخيصMIT
الروابط
  • اربط الأدوات بسير عمل الذكاء الاصطناعي

    يتيح Enhanced Grok Search MCP Server إمكانات MCP التي يمكن لتطبيقات الذكاء الاصطناعي العميلة ووكلاء الذكاء الاصطناعي المتوافقة استخدامها.

  • الأدوات المتاحة: 5

    تصفّح الإجراءات القابلة للاستدعاء أدناه، بما في ذلك أسماؤها وأوصافها عندما يوفّرها الخادم.

  • إعدادات جاهزة للنسخ

    استخدم أمثلة إعداد التثبيت لتهيئة هذا الخادم في تطبيق MCP العميل المفضّل لديك.

  • مؤشرات الاهتمام بالمصدر المفتوح

    النجوم: 19، والنسخ المتفرعة: 3 في المستودع المرتبط.

Enhanced Grok Search MCP Server

A robust MCP (Model Context Protocol) server that provides comprehensive web search and analysis capabilities using xAI's Grok API.

Features

🔍 Search Capabilities

  • Web Search: Search general web content using Grok's AI-powered search
  • News Search: Search for recent news and current events with timeline analysis
  • Twitter/X Search: Search social media posts with sentiment analysis
  • Date Range Filtering: Search within specific time periods

📊 Analysis Modes

  • Basic Mode: Traditional search results with titles, snippets, and URLs
  • Comprehensive Mode: Rich analysis including:
    • Detailed timelines of events
    • Direct quotes with full attribution
    • Multiple perspectives and viewpoints
    • Historical context and implications
    • Fact verification status
    • Key findings categorization

🛡️ Reliability Features

  • Retry Logic: Automatic retry with exponential backoff for failed requests
  • Request Timeouts: Configurable timeouts to prevent hanging
  • Graceful Error Handling: Comprehensive error responses with detailed context
  • Health Monitoring: Built-in health checks and performance metrics
  • Caching: Intelligent caching for comprehensive analyses
  • Input Validation: Enhanced sanitization and validation of all inputs

🔧 Technical Features

  • NPX Compatible: Easy installation and usage via NPX
  • MCP Protocol: Full compatibility with MCP clients like Claude Desktop
  • Structured Logging: Comprehensive logging for debugging and monitoring
  • Performance Metrics: Request tracking and success rate monitoring

Installation

Simple 3-Step Process

bash
git clone https://github.com/stat-guy/grok-search-mcp.git
cd grok-search-mcp
npm install -g .

Verify Installation

Test that the installation worked:

bash
npx grok-search-mcp --help

Success indicator: If you see Grok Search MCP Server running on stdio, your installation is ready!

Alternative: NPX Usage

bash
npx grok-search-mcp

Setup

1. Get Your xAI API Key

  1. Visit the xAI Developer Portal
  2. Create an account or sign in
  3. Generate your API key
  4. Copy the API key for the next step

2. Configure Environment Variable

Set your xAI API key as an environment variable:

bash
export XAI_API_KEY="your-api-key-here"

Or create a .env file in your project:

XAI_API_KEY=your-api-key-here

3. Configure Claude Desktop

Add the server to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json

json
{
  "mcpServers": {
    "grok-search": {
      "command": "npx",
      "args": ["grok-search-mcp"],
      "env": {
        "XAI_API_KEY": "your-api-key-here"
      }
    }
  }
}

Available Tools

grok_search

General-purpose search tool with configurable search types and analysis modes.

Parameters:

  • query (required): The search query
  • search_type (optional): "web", "news", or "general" (default: "web")
  • analysis_mode (optional): "basic" or "comprehensive" (default: "basic")
  • max_results (optional): Maximum number of results (1-20, default: 10)
  • from_date (optional): Start date in YYYY-MM-DD format
  • to_date (optional): End date in YYYY-MM-DD format

Basic Mode Example:

json
{
  "query": "latest AI developments",
  "search_type": "news",
  "max_results": 5
}

Comprehensive Mode Example:

json
{
  "query": "US Iran conflict 2025",
  "search_type": "news",
  "analysis_mode": "comprehensive",
  "max_results": 10,
  "from_date": "2025-06-20",
  "to_date": "2025-06-24"
}

grok_web_search

Search general web content with comprehensive analysis support.

Parameters:

  • query (required): The web search query
  • analysis_mode (optional): "basic" or "comprehensive" (default: "basic")
  • max_results (optional): Maximum number of results (1-20, default: 10)
  • from_date (optional): Start date in YYYY-MM-DD format
  • to_date (optional): End date in YYYY-MM-DD format

grok_news_search

Search for recent news with comprehensive timeline and context analysis.

Parameters:

  • query (required): The news search query
  • analysis_mode (optional): "basic" or "comprehensive" (default: "basic")
  • max_results (optional): Maximum number of results (1-20, default: 10)
  • from_date (optional): Start date in YYYY-MM-DD format
  • to_date (optional): End date in YYYY-MM-DD format

grok_twitter

Search Twitter/X posts with social media analysis.

Parameters:

  • query (required): The search query for tweets
  • handles (optional): Array of Twitter handles to filter by (without @ symbol)
  • analysis_mode (optional): "basic" or "comprehensive" (default: "basic")
  • max_results (optional): Maximum number of results (1-20, default: 10)
  • from_date (optional): Start date in YYYY-MM-DD format
  • to_date (optional): End date in YYYY-MM-DD format

health_check

Check server health and API connectivity status.

Parameters: None

Response Formats

Basic Mode Response

json
{
  "query": "search query",
  "analysis_mode": "basic",
  "results": [
    {
      "title": "Result Title",
      "snippet": "Brief description or excerpt",
      "url": "https://example.com",
      "source": "source-name",
      "published_date": "2025-06-24",
      "author": "Author Name",
      "citation_url": "https://example.com",
      "citation_metadata": {
        "domain": "example.com",
        "is_secure": true
      }
    }
  ],
  "citations": ["https://example.com"],
  "summary": "Brief overview of findings",
  "total_results": 5,
  "search_time": "2025-06-24T12:00:00.000Z",
  "source": "grok-live-search"
}

Comprehensive Mode Response

json
{
  "query": "search query",
  "analysis_mode": "comprehensive",
  "comprehensive_analysis": "Detailed analysis with context and implications...",
  "key_findings": [
    {
      "category": "main_story",
      "title": "Primary Development",
      "content": "Detailed explanation with specifics",
      "sources": ["https://source1.com", "https://source2.com"],
      "confidence": "high"
    }
  ],
  "timeline": [
    {
      "date": "2025-06-21",
      "event": "Initial event occurred",
      "source": "News Source",
      "significance": "This marked the beginning of..."
    }
  ],
  "direct_quotes": [
    {
      "quote": "This is an exact quote from the source",
      "speaker": "Official Name",
      "context": "During a press conference on Monday",
      "source_url": "https://source.com",
      "significance": "This statement clarifies the position..."
    }
  ],
  "related_context": "Historical background and connections...",
  "multiple_perspectives": [
    {
      "viewpoint": "Supporters",
      "content": "Analysis from this perspective",
      "sources": ["https://supporting-source.com"],
      "reasoning": "This group supports because..."
    }
  ],
  "implications": {
    "short_term": "Immediate consequences include...",
    "long_term": "Potential long-term impacts are...",
    "stakeholders_affected": ["Group 1", "Group 2"]
  },
  "verification_status": {
    "confirmed_facts": ["Verified information"],
    "unconfirmed_claims": ["Unverified claims"],
    "contradictory_information": ["Conflicting reports"]
  },
  "raw_results": [
    {
      "title": "Source Article",
      "snippet": "Brief description",
      "url": "https://example.com",
      "relevance_score": 9
    }
  ],
  "summary": "Executive summary of the entire analysis",
  "total_results": 10,
  "search_time": "2025-06-24T12:00:00.000Z",
  "source": "grok-comprehensive-analysis"
}

Configuration

Environment Variables

  • XAI_API_KEY (required): Your xAI API key
  • GROK_TIMEOUT (optional): Request timeout in milliseconds (default: 30000)
  • GROK_MAX_RETRIES (optional): Maximum retry attempts (default: 3)

Claude Desktop Configuration Example

json
{
  "mcpServers": {
    "grok-search": {
      "command": "npx",
      "args": ["grok-search-mcp"],
      "env": {
        "XAI_API_KEY": "your-api-key-here",
        "GROK_TIMEOUT": "45000",
        "GROK_MAX_RETRIES": "5"
      }
    }
  }
}

Error Handling

The server includes comprehensive error handling with standardized error responses:

  • Invalid API Key: Graceful degradation with clear error messages
  • Empty Query: Enhanced validation with detailed feedback
  • API Rate Limits: Automatic retry with exponential backoff
  • Network Issues: Connection error handling with retry logic
  • Timeout Issues: Configurable timeouts with clear error reporting
  • JSON Parsing: Multiple parsing strategies with fallback handling

Error Response Format

json
{
  "error": "Detailed error message",
  "status": "failed",
  "query": "original query",
  "search_type": "web",
  "analysis_mode": "basic",
  "timestamp": "2025-06-24T12:00:00.000Z",
  "request_id": "req_1234567890_abc123"
}

Performance Features

Caching

  • Comprehensive Analysis Caching: Intelligent caching for expensive comprehensive analyses
  • TTL Management: Configurable cache expiration (default: 30 minutes)
  • Memory Management: Automatic cache size limits to prevent memory issues

Monitoring

  • Health Checks: Built-in health monitoring with detailed status reporting
  • Performance Metrics: Request tracking, success rates, and timing analysis
  • Structured Logging: JSON-formatted logs for easy parsing and monitoring

Reliability

  • Retry Logic: Exponential backoff for transient failures
  • Circuit Breaking: Graceful degradation when API is unavailable
  • Input Sanitization: Comprehensive input validation and cleaning
  • Error Recovery: Multiple JSON parsing strategies for robust response handling

Troubleshooting

Common Issues

  1. "API service is not available"

    • Check if XAI_API_KEY is set correctly
    • Verify your API key is valid and active
    • Use the health_check tool to diagnose API connectivity
  2. "Request timeout after Xms"

    • Increase GROK_TIMEOUT environment variable
    • Check your internet connection
    • Consider using basic mode for faster responses
  3. "Search query too long"

    • Queries are limited to 1000 characters
    • Break down complex queries into smaller parts
  4. Empty or poor results in comprehensive mode

    • Try different query phrasings
    • Use basic mode for simple searches
    • Check if the topic has sufficient recent coverage

Health Monitoring

Use the health_check tool to get detailed status:

json
{
  "tool": "health_check"
}

Example health response:

json
{
  "server_healthy": true,
  "api_healthy": true,
  "uptime_ms": 3600000,
  "total_requests": 150,
  "error_count": 3,
  "success_rate": "98.00%",
  "api_details": {
    "hasApiKey": true,
    "cacheSize": 12
  }
}

Debugging

The server provides structured logging. Monitor stderr output for detailed logs:

bash
npx grok-search-mcp 2>debug.log

Testing

Run the test suite to verify functionality:

bash
# With API key
XAI_API_KEY=your-key npm test

# Basic functionality test (may skip API calls)
npm test

Usage Examples

Basic News Search

json
{
  "query": "latest technology news",
  "search_type": "news",
  "max_results": 5
}

Comprehensive Analysis

json
{
  "query": "climate change policy 2025",
  "analysis_mode": "comprehensive",
  "search_type": "news",
  "from_date": "2025-01-01",
  "max_results": 15
}

Twitter Analysis with Specific Handles

json
{
  "query": "AI developments",
  "handles": ["elonmusk", "OpenAI", "AnthropicAI"],
  "analysis_mode": "comprehensive",
  "max_results": 10
}

Date-Filtered Web Search

json
{
  "query": "quantum computing breakthroughs",
  "search_type": "web",
  "from_date": "2025-06-01",
  "to_date": "2025-06-24",
  "max_results": 8
}

API Limits

  • Rate limits depend on your xAI API plan
  • Monitor usage through the xAI Developer Portal
  • Comprehensive mode uses more tokens than basic mode
  • Caching helps reduce API usage for repeated queries

License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

Support

For issues and feature requests, please create an issue in the repository.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Update documentation
  6. Submit a pull request

Changelog

Version 2.0.0 (Enhanced)

  • ✅ Added comprehensive analysis mode with rich context
  • ✅ Implemented timeline extraction and direct quotes
  • ✅ Added multiple perspectives analysis
  • ✅ Enhanced error handling with retry logic
  • ✅ Added intelligent caching for comprehensive analyses
  • ✅ Implemented health monitoring and performance metrics
  • ✅ Added structured logging system
  • ✅ Enhanced input validation and sanitization
  • ✅ Added configurable timeouts and retry settings
  • ✅ Improved JSON parsing with multiple fallback strategies

التثبيت

TypingMind
{
  "mcpServers": {
    "grok-search-mcp": {
      "command": "npx",
      "args": [
        "grok-search-mcp"
      ],
      "env": {
        "XAI_API_KEY": "<XAI_API_KEY>"
      }
    }
  }
}

الأدوات المتاحة

  • web_search

    Performs a third-party web search based on the given query and returns the results as a JSON string.

    The query should be a clear, self-contained natural-language search query. When helpful, include constraints such as topic, time range, language, or domain.

    The platform should be the platforms which you should focus on searching, such as "Twitter", "GitHub", "Reddit", etc.

    The min_results and max_results should be the minimum and maximum number of results to return.

    Returns

    A JSON-encoded string representing a list of search results. Each result includes at least:

    • url: the link to the result
    • title: a short title
    • summary: a brief description or snippet of the page content.
  • web_fetch

    Fetches and extracts the complete content from a specified URL and returns it as a structured Markdown document.

    The url should be a valid HTTP/HTTPS web address pointing to the target page. Ensure the URL is complete and accessible (not behind authentication or paywalls).

    The function will:

    • Retrieve the full HTML content from the URL
    • Parse and extract all meaningful content (text, images, links, tables, code blocks)
    • Convert the HTML structure to well-formatted Markdown
    • Preserve the original content hierarchy and formatting
    • Remove scripts, styles, and other non-content elements

    Returns

    A Markdown-formatted string containing:

    • Metadata header (source URL, title, fetch timestamp)
    • Table of Contents (if applicable)
    • Complete page content with preserved structure
    • All text, links, images, tables, and code blocks from the original page

    The output maintains 100% content fidelity with the source page and is ready for documentation, analysis, or further processing.

  • get_config_info

    Returns the current Grok Search MCP server configuration information and tests the connection.

    This tool is useful for:

    • Verifying that environment variables are correctly configured
    • Testing API connectivity by sending a request to /models endpoint
    • Debugging configuration issues
    • Checking the current API endpoint and settings

    Returns

    A JSON-encoded string containing configuration details:

    • api_url: The configured Grok API endpoint
    • api_key: The API key (masked for security, showing only first and last 4 characters)
    • model: The currently selected model for search and fetch operations
    • debug_enabled: Whether debug mode is enabled
    • log_level: Current logging level
    • log_dir: Directory where logs are stored
    • config_status: Overall configuration status (✅ complete or ❌ error)
    • connection_test: Result of testing API connectivity to /models endpoint
      • status: Connection status
      • message: Status message with model count
      • response_time_ms: API
  • switch_model

    Switches the default Grok model used for search and fetch operations, and persists the setting.

    This tool is useful for:

    • Changing the AI model used for web search and content fetching
    • Testing different models for performance or quality comparison
    • Persisting model preference across sessions

    Parameters

    model : str The model ID to switch to (e.g., "grok-4-fast", "grok-4.1")

    Returns

    A JSON-encoded string containing:

    • status: Success or error status
    • previous_model: The model that was being used before
    • current_model: The newly selected model
    • message: Status message
    • config_file: Path where the model preference is saved

    Notes

    • The model setting is persisted to ~/.config/grok-search/config.json
    • This setting will be used for all future search and fetch operations
    • You can verify available models using the get_config_info tool
  • toggle_builtin_tools

    Toggle Claude Code's built-in WebSearch and WebFetch tools on/off.

    Parameters: action - "on" (block built-in), "off" (allow built-in), "status" (check) Returns: JSON with current status and deny list

استخدم MCP الخاص بـ Enhanced Grok Search MCP Server مع نماذج ذكاء اصطناعي متعددة

يربط TypingMind أدوات MCP على مستوى مساحة العمل، لذا بمجرد توصيل Enhanced Grok Search MCP Server، يمكنك استخدامه مع نماذج ذكاء اصطناعي مختلفة في TypingMind بدلًا من إعداده لكل نموذج على حدة. يعمل تكامل MCP هذا محليًا عبر موصل MCP الخاص بـ TypingMind على جهازك.

دليل الإعداد لاستخدام الموصل المحلي

استخدم هذا الخيار عندما يحتاج خادم MCP إلى الوصول إلى ملفات محلية أو تطبيقات أو موارد خاصة على جهاز الكمبيوتر لديك.

1

فتح إعدادات MCP

في TypingMind، انتقل إلى «الإعدادات»، ثم «الإعدادات المتقدمة»، ثم «بروتوكول سياق النموذج»، واختر «إعداد الموصل».

  1. افتح TypingMind في متصفحك.
  2. انقر على أيقونة الإعدادات.
  3. انتقل إلى الإعدادات المتقدمة.
  4. افتح قسم بروتوكول سياق النموذج.
  5. انقر على «إعداد الموصل» واختر «هذا الجهاز».
شاشة إعداد موصل MCP في TypingMind مع تحديد «هذا الجهاز»
2

تنفيذ أمر الموصل

اختر «هذا الجهاز»، وانسخ الأمر من TypingMind وشغّله في Terminal. أبقِ العملية قيد التشغيل أثناء استخدام MCP.

  1. انسخ أمر الإعداد الذي يعرضه TypingMind.
  2. افتح Terminal على macOS أو Windows Terminal على Windows.
  3. الصق الأمر ونفّذه.
  4. وافق على تثبيت الحزمة إذا طلب منك Terminal تأكيد المتابعة.
  5. أبقِ نافذة Terminal والعملية التي تعمل فيها قيد التشغيل أثناء استخدام أدوات MCP.
3

أضف Enhanced Grok Search MCP Server كخادم

عندما تظهر حالة الموصل «جاهز»، انقر على «تعديل الخوادم» والصق إعدادات خادم MCP.

  1. انتظر حتى تظهر حالة الموصل «جاهز».
  2. انقر على «تعديل الخوادم».
  3. الصق إعدادات خادم MCP الخاص بـ Enhanced Grok Search MCP Server.
  4. احفظ قائمة الخوادم.
  5. حدّث الحالة إذا أردت التأكد من أن الموصل لا يزال جاهزًا.
إعدادات MCP في TypingMind تعرض خادمًا نشطًا وزر «تعديل الخوادم»
{
  "mcpServers": {
    "grok-search-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "grok-search-mcp"
      ]
    }
  }
}
4

استخدام الاتصال مع نماذج مختلفة

احفظ قائمة الخوادم، وافتح «الإضافات»، وفعّل أدوات MCP الخاصة بـ Enhanced Grok Search MCP Server، ثم اختر أي نموذج ذكاء اصطناعي مدعوم في TypingMind واستخدم الأدوات في المحادثة أو أسندها إلى وكيل ذكاء اصطناعي.

  1. افتح صفحة الإضافات في TypingMind.
  2. فعّل أدوات MCP الخاصة بـ Enhanced Grok Search MCP Server.
  3. ابدأ محادثة واختر نموذج الذكاء الاصطناعي الذي تريد استخدامه.
  4. استخدم أدوات MCP في المحادثة أو عيّنها لوكيل ذكاء اصطناعي.
  5. انتقل إلى نموذج ذكاء اصطناعي آخر عند الحاجة دون إعادة الاتصال بـ MCP.
محادثة في TypingMind تستخدم أدوات MCP المفعّلة مع نموذج ذكاء اصطناعي محدّد
هل يمكنك استخدام Enhanced Grok Search MCP Server لمساعدتي في هذه المهمة؟
Enhanced Grok Search MCP Server
بالتأكيد. قرأته.
إليك ما وجدته باستخدام Enhanced Grok Search MCP Server.

الأسئلة الشائعة

ما استخدامات خادم MCP Enhanced Grok Search MCP Server؟

Enhanced Grok Search MCP Server هو خادم MCP يتيح لتطبيقات الذكاء الاصطناعي المتوافقة الاتصال بأدوات ومصادر سياق خارجية. في TypingMind، يمكنك إضافة خادم MCP هذا مرة واحدة وإتاحة أدواته في مساحة عملك للذكاء الاصطناعي.

هل يمكنني استخدام خادم MCP Enhanced Grok Search MCP Server مع نماذج ذكاء اصطناعي متعددة في TypingMind؟

نعم. يربط TypingMind أدوات MCP على مستوى مساحة العمل، لذا يمكنك استخدام Enhanced Grok Search MCP Server مع نماذج ذكاء اصطناعي مختلفة مثل Claude أو ChatGPT أو Gemini أو غيرها من النماذج التي أعددتها في TypingMind، دون إعداد خادم MCP لكل نموذج على حدة.

لماذا تستخدم موصل MCP Enhanced Grok Search MCP Server مع TypingMind؟

يُعد TypingMind من أفضل واجهات المحادثة مع النماذج اللغوية الكبيرة، إذ يجمع نماذج ذكاء اصطناعي متعددة ومطالبات وإضافات ووكلاء ذكاء اصطناعي ومفاتيح API وأدوات MCP في مساحة عمل واحدة. بعد توصيل Enhanced Grok Search MCP Server، يمكنك استخدام أدوات MCP الخاصة به عبر نماذجك المفضلة مع الحفاظ على سير عمل محادثاتك منظمًا في TypingMind.

كيف أوصّل خادم MCP Enhanced Grok Search MCP Server بـ TypingMind؟

يعمل Enhanced Grok Search MCP Server عبر موصل MCP المحلي في TypingMind. هذا هو الخيار الأنسب عندما يحتاج خادم MCP إلى الوصول إلى ملفات محلية أو تطبيقات سطح المكتب أو أدوات سطر الأوامر أو موارد خاصة على حاسوبك.

ما الأدوات التي يوفّرها خادم MCP Enhanced Grok Search MCP Server في TypingMind؟

يتيح Enhanced Grok Search MCP Server أدوات MCP بعدد 5، يمكنك تفعيلها من صفحة الإضافات في TypingMind واستخدامها في المحادثات أو تعيينها لوكلاء ذكاء اصطناعي.

هل أحتاج إلى مشاركة مفاتيح API الخاصة بي مع TypingMind لاستخدام خادم MCP Enhanced Grok Search MCP Server؟

لا. يعطي TypingMind الأولوية للعمل المحلي ويُبقي مزوّدي النماذج ومفاتيح API والمطالبات وإعدادات MCP تحت تحكمك. إذا كان Enhanced Grok Search MCP Server يتطلب مصادقة، فأضف الترويسات أو إعدادات OAuth أو الإعدادات المحلية المطلوبة لخادم MCP هذا عند إنشاء الاتصال.

خوادم MCP ذات صلة

عرض الكل

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا البريدية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇