UNPKG

xai-live-search-mcp

Version:

šŸ”„ xAI Live Search integration for Claude Code via MCP - BEAST MODE!

219 lines (166 loc) • 5.84 kB
# šŸ”„ xAI Live Search MCP Server - CRACKED-JACKED Edition **BEAST MODE** xAI Live Search integration for Claude Code via Model Context Protocol (MCP). ## šŸš€ Features - **Live Web Search**: Real-time search using xAI's Grok with current data - **AI Chat with Search**: Enhanced AI responses with live web context - **Multiple Search Types**: Web, News, and X (Twitter) searches - **Full MCP Integration**: Seamless Claude Code integration - **Type-Safe**: Full TypeScript implementation with validation - **Error Handling**: Robust error handling and validation ## ⚔ Quick Setup ### šŸš€ Super Easy NPM Installation (RECOMMENDED) #### Option 1: One-Command Setup ```bash # Install globally npm install -g xai-live-search-mcp # Run setup wizard (guides you through API key configuration) xai-mcp-setup # OR xai-live-search-mcp --setup # Add to Claude Code project claude mcp add xai-live-search -- xai-live-search-mcp ``` #### Option 2: Quick Setup (if you have API key) ```bash # Set your API key export XAI_API_KEY="your-xai-api-key-here" # Add to Claude Code project in one command claude mcp add xai-live-search -- npx xai-live-search-mcp ``` ### šŸ“¦ Alternative Installation Methods #### Local Project Install ```bash # Install in specific project npm install xai-live-search-mcp # Run setup wizard npx xai-live-search-mcp setup # Add to Claude Code claude mcp add xai-live-search -- npx xai-live-search-mcp ``` #### Development Install ```bash git clone <repository> cd xai-live-search-mcp npm install && npm run build claude mcp add xai-live-search -- node dist/index.js ``` ### šŸ”‘ API Key Configuration #### Method 1: Setup Wizard (EASIEST) ```bash # If installed globally xai-mcp-setup # OR xai-live-search-mcp --setup # If installed locally npx xai-live-search-mcp --setup # OR node setup-wizard.cjs ``` #### Method 2: Environment Variable ```bash export XAI_API_KEY="your-xai-api-key-here" ``` #### Method 3: .env File ```bash cp .env.example .env # Edit .env with your API key ``` #### Method 4: MCP Tool (in Claude Code) ``` Use xai_configure tool: { "apiKey": "your-xai-api-key-here", "model": "grok-3-latest" } ``` **Get your API key from:** [https://x.ai/api](https://x.ai/api) ## šŸ› ļø Available Tools ### 1. `xai_configure` Configure your xAI API settings. **Parameters:** - `apiKey` (required): Your xAI API key - `model` (optional): Model to use (default: 'grok-3') - `maxTokens` (optional): Max tokens per request (default: 4096) - `temperature` (optional): Response creativity 0.0-2.0 (default: 0.7) ### 2. `xai_live_search` Perform live web searches with real-time data. **Parameters:** - `query` (required): What to search for - `maxResults` (optional): Max results 1-20 (default: 10) - `searchType` (optional): 'web', 'news', or 'x' (default: 'web') - `includeTimestamp` (optional): Include timestamps (default: true) ### 3. `xai_chat_with_search` Chat with AI using live search context. **Parameters:** - `message` (required): Your question/message - `includeContext` (optional): Show search results (default: true) - `maxSearchResults` (optional): Max search results 1-10 (default: 5) - `searchQuery` (optional): Specific search query ### 4. `xai_test_connection` Test your API connection and authentication. ## šŸ’Ŗ Usage Examples ### Basic Configuration ``` Use the xai_configure tool with your API key to get started. ``` ### Live Search ``` Use xai_live_search to search for "latest AI developments 2025" ``` ### AI Chat with Search ``` Use xai_chat_with_search to ask "What are the latest developments in quantum computing?" ``` ## šŸ”§ Development ### Scripts - `npm run build` - Build TypeScript to JavaScript - `npm run dev` - Development mode with auto-reload - `npm start` - Start the built server - `npm test` - Run tests ### Project Structure ``` src/ ā”œā”€ā”€ index.ts # Main MCP server ā”œā”€ā”€ xai-client.ts # xAI API client ā”œā”€ā”€ types.ts # TypeScript types and schemas └── __tests__/ # Test files ``` ## šŸ›”ļø Security Notes - Never commit your xAI API key to version control - Use environment variables for production deployments - API keys are stored in memory only during server runtime ## šŸš€ Integration with Claude Code Once configured, you can use these tools directly in Claude Code: 1. **Configure**: Set up your xAI API key 2. **Search**: Get real-time information from the web 3. **Chat**: Ask questions with live context 4. **Integrate**: Use in your development workflow ## šŸ’” Pro Tips - Use specific search queries for better results - Try different search types (web/news/x) for varied perspectives - Combine with other MCP servers for maximum BEAST MODE power - Use in development to get latest documentation and trends ## šŸ›”ļø Security & Privacy ### **API Key Safety** - āœ… **Never committed to code** - Your API keys are safe - āœ… **Secure file permissions** - .env files set to 600 (owner-only) - āœ… **Multiple configuration options** - Choose what works for you - āœ… **No keys in published package** - Clean NPM distribution ### **Best Practices** 1. **Use environment variables** for production 2. **Rotate API keys regularly** 3. **Monitor API usage** and set limits 4. **Use project-specific keys** for different environments ## šŸ“¦ Publishing & Distribution This package can be safely published to NPM registries: - No API keys included in published package - Interactive setup wizard for new users - Secure configuration management - Standard NPM distribution practices ```bash # Publish to NPM (maintainers only) ./publish-npm.sh ``` ## šŸ”„ BEAST MODE ACTIVATED! This MCP server brings REAL-TIME web search directly into Claude Code. No more outdated information - only the FRESHEST data from the web! **LET'S CRUSH THOSE INFORMATION GAPS! šŸ’ŖšŸš€**