xai
Use for xAI/Grok API capabilities through the lfg xai_grok MCP — text generation, web search, X/Twitter search, image/video generation, and TTS. Load when the user wants Grok-connected xAI tools beyon
SKILL.mdskills/xai/SKILL.md
GitHubxAI (Grok-connected)
One skill for all lfg xai_grok MCP tools (~/.grok/plugins/lfg/mcp-runtimes/xai-grok-mcp). Use this skill instead of guessing tool names.
Setup check
- Run
lfg setup --runso the plugin shipsxai_grokand lfg mirrors it into~/.grok/config.tomlas[mcp_servers.xai_grok](required for the Grok /mcps UI). Reload MCP withrin/mcpsor start a new session. - Credentials (priority): dedicated
~/.grok/xai-grok-mcp-auth.jsonvialfg xai auth set-api-key,lfg xai auth set-oauth, or the MCP toolsxai_auth_set_api_key/xai_auth_set_oauth; thenXAI_API_KEY; then read-only Grok host~/.grok/auth.json(host file is never written by xai_grok MCP). Never log tokens or keys. - Do not use
/mcpsOAuth authenticate (i) forxai_grok: Grok only runs that host-managed OAuth flow for HTTP/SSE MCP servers, whilexai_grokis local stdio. Usexai_auth_*tools instead.
Tool flow (all capabilities)
search_toolwith a specific query, e.g."xai web search","xai x search","xai image generate".- Call the qualified MCP tool via
use_toolusing the exact schema from step 1 (server is typicallyxai_grok; tool names use underscores:xai_web_search, not hyphens).
Capability router
| User intent | MCP tool | search_tool hint |
|---|---|---|
| Draft, rewrite, summarize, reason (no live web) | xai_generate_text |
xai generate text |
| Current web info + citations | xai_web_search |
xai web search |
| X/Twitter posts, handles, real-time social | xai_x_search |
xai x search |
| Still images (Grok Imagine) | xai_image_generate |
xai image generate |
| Video (text/image/reference) | xai_video_generate |
xai video generate |
| Speech / TTS | xai_tts |
xai tts |
Details and example payloads: references/tools.md.
Cross-cutting rules
- Text vs search: Use
xai_generate_textfor closed-book generation; usexai_web_searchorxai_x_searchwhen recency or sources matter. - X evidence: Treat posts as leads or primary-source quotes only with relevant account identity; corroborate facts via web/docs before asserting them as settled.
- Artifacts: Image/video tools may return URLs, base64, or local paths under
.grok-xai-artifactswhen the schema supportsartifact_dir. - Fallback: If
xai_grokis disconnected, say so explicitly; use host-nativeweb_search/x_searchonly if the user still wants a fallback.
Credential safety
Use credentials exposed by the Grok host or MCP server only. Never print, quote, summarize, or store OAuth tokens, refresh tokens, bearer tokens, or API keys.