Skip to main content
Glama
BasisSetVentures

Grok CLI MCP Server

usage_examples.py3.76 kB
""" Example usage patterns for grok-cli-mcp tools. These examples show the structure of tool calls made through MCP clients like Claude Code. The actual execution happens through the MCP protocol. """ import asyncio async def example_simple_query() -> None: """Example: Simple query to Grok.""" print("Example 1: Simple Query") print("-" * 50) print("Tool: grok_query") print("Arguments:") print(" prompt: 'What is the capital of France?'") print(" model: 'grok-code-fast-1'") print() print("Expected response: 'Paris is the capital of France...'") print() async def example_multi_turn_chat() -> None: """Example: Multi-turn conversation.""" print("Example 2: Multi-turn Chat") print("-" * 50) print("Tool: grok_chat") print("Arguments:") print(" messages:") print(" - {role: 'user', content: 'What is MCP?'}") print(" - {role: 'assistant', content: 'MCP is the Model Context Protocol...'}") print(" - {role: 'user', content: 'How do I create a server?'}") print(" timeout_s: 120") print() print("Expected response: Detailed explanation of creating an MCP server...") print() async def example_code_generation() -> None: """Example: Generate code with context.""" print("Example 3: Code Generation") print("-" * 50) print("Tool: grok_code") print("Arguments:") print(" task: 'Create a function to validate email addresses'") print(" language: 'python'") print(" context: 'Use regex, return bool, handle edge cases'") print(" timeout_s: 180") print() print("Expected response: Python function with email validation...") print() async def example_raw_output() -> None: """Example: Get structured response with raw CLI output.""" print("Example 4: Raw Output Mode") print("-" * 50) print("Tool: grok_query") print("Arguments:") print(" prompt: 'Explain async/await'") print(" raw_output: True") print() print("Expected response structure:") print(" {") print(" 'text': '...',") print(" 'messages': [{role: 'assistant', content: '...'}],") print(" 'raw': '...', # Raw CLI output") print(" 'model': 'grok-code-fast-1'") print(" }") print() async def example_with_timeout() -> None: """Example: Custom timeout for long-running queries.""" print("Example 5: Custom Timeout") print("-" * 50) print("Tool: grok_code") print("Arguments:") print(" task: 'Generate a complete REST API for a blog platform'") print(" language: 'typescript'") print(" timeout_s: 300 # 5 minutes for complex task") print() print("Expected response: Comprehensive TypeScript REST API implementation...") print() async def main() -> None: """Run all examples.""" print("=" * 50) print("GROK-CLI-MCP USAGE EXAMPLES") print("=" * 50) print() print("These examples demonstrate how to call grok-cli-mcp tools") print("through MCP clients like Claude Code, Cline, or Cursor.") print() print("Actual calls are made through the MCP protocol, not directly") print("from Python code. These examples show the structure only.") print() print("=" * 50) print() await example_simple_query() await example_multi_turn_chat() await example_code_generation() await example_raw_output() await example_with_timeout() print("=" * 50) print("For more information, see:") print("- README.md: Installation and configuration") print("- docs/architecture.md: Design decisions and tradeoffs") print("- docs/troubleshooting.md: Common issues and solutions") print("=" * 50) if __name__ == "__main__": asyncio.run(main())

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/BasisSetVentures/grok-cli-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server