Skip to main content
Glama

MCP Server for Splunk

Apache 2.0
16
  • Apple
  • Linux
test_env_vars.pyβ€’4.29 kB
#!/usr/bin/env python3 """ Test script to verify environment variables are properly loaded. This script checks if all required environment variables for the OpenAI agent and Splunk connection are available in the container environment. """ import os import sys def test_env_vars(): """Test if environment variables are properly loaded.""" print("πŸ” Testing Environment Variables") print("=" * 50) # Define required and optional environment variables required_vars = { "SPLUNK_HOST": "Splunk server hostname", "SPLUNK_USERNAME": "Splunk username", "SPLUNK_PASSWORD": "Splunk password", } optional_vars = { "SPLUNK_PORT": "Splunk management port (default: 8089)", "SPLUNK_VERIFY_SSL": "Verify SSL certificates (default: false)", "OPENAI_API_KEY": "OpenAI API key for agent functionality", "OPENAI_MODEL": "OpenAI model (default: gpt-4o)", "OPENAI_TEMPERATURE": "OpenAI temperature (default: 0.7)", "OPENAI_MAX_TOKENS": "OpenAI max tokens (default: 4000)", "MCP_HOT_RELOAD": "Enable hot reload (development)", "MCP_SERVER_MODE": "Server mode (docker/local)", } all_good = True # Check required variables print("πŸ“‹ Required Variables:") for var_name, description in required_vars.items(): value = os.getenv(var_name) if value: # Mask sensitive values if "PASSWORD" in var_name or "KEY" in var_name: display_value = f"***{value[-3:]}" if len(value) > 3 else "***" else: display_value = value print(f" βœ… {var_name}: {display_value}") else: print(f" ❌ {var_name}: NOT SET - {description}") all_good = False print("\nπŸ“‹ Optional Variables:") for var_name, description in optional_vars.items(): value = os.getenv(var_name) if value: # Mask sensitive values if "PASSWORD" in var_name or "KEY" in var_name: display_value = f"***{value[-3:]}" if len(value) > 3 else "***" else: display_value = value print(f" βœ… {var_name}: {display_value}") else: print(f" βšͺ {var_name}: Not set - {description}") # Test agent tools (if available) try: from src.tools.agents.dynamic_troubleshoot_agent import DynamicTroubleshootAgentTool from src.tools.agents.splunk_triage_agent import SplunkTriageAgentTool print("βœ… Agent tools imported successfully") # Test agent instantiation SplunkTriageAgentTool("agent_troubleshoot", "troubleshooting") DynamicTroubleshootAgentTool("dynamic_troubleshoot", "troubleshooting") print("βœ… Agent tools instantiated successfully") except ImportError as e: print(f"⚠️ Agent tools not available: {e}") except Exception as e: print(f"❌ Agent tools test failed: {e}") # Test Splunk client configuration print("\nπŸ”Œ Splunk Client Configuration Test:") try: from src.client.splunk_client import get_splunk_config config = get_splunk_config() print(" βœ… Splunk configuration loaded successfully") print(f" 🌐 Host: {config.get('host', 'Not set')}") print(f" πŸ”Œ Port: {config.get('port', 'Not set')}") print(f" πŸ‘€ Username: {config.get('username', 'Not set')}") # Test password (masked) password = config.get("password") if password: print(f" πŸ” Password: ***{password[-3:] if len(password) > 3 else '***'}") else: print(" πŸ” Password: Not set") print(f" πŸ”’ SSL Verify: {config.get('verify', 'Not set')}") except Exception as e: print(f" ❌ Failed to load Splunk configuration: {e}") all_good = False # Summary print("\n" + "=" * 50) if all_good: print("πŸŽ‰ All required environment variables are properly configured!") return 0 else: print("⚠️ Some required environment variables are missing.") print("πŸ’‘ Make sure your .env file is properly configured and loaded.") return 1 if __name__ == "__main__": sys.exit(test_env_vars())

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/deslicer/mcp-for-splunk'

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