Skip to main content
Glama

Databricks MCP Server

by samhavens
test_direct.py•2.34 kB
""" Direct tests for the Databricks MCP server. This module contains tests that directly instantiate and test the server without using MCP protocol. """ import asyncio import json import logging import sys from typing import Dict, Any, List # from src.server.databricks_mcp_server import DatabricksMCPServer # Direct server class not available - switching to simple_databricks_mcp_server functions from src.server.simple_databricks_mcp_server import list_clusters # Configure logging logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') logger = logging.getLogger(__name__) async def test_list_clusters(): """Test the list_clusters tool directly.""" try: logger.info("Testing list_clusters function directly") # Call the function directly result = await list_clusters() logger.info(f"Result: {result}") # The result should be a JSON string, try to parse it try: parsed_result = json.loads(result) logger.info(f"Parsed result: {json.dumps(parsed_result, indent=2)}") # Check if it contains cluster data if 'clusters' in parsed_result: clusters = parsed_result['clusters'] logger.info(f"Found {len(clusters)} clusters") return True elif 'error' in parsed_result: logger.warning(f"API returned error: {parsed_result['error']}") return True # Still successful test, just no clusters or auth issue else: logger.info("Result received but no clusters field found") return True except json.JSONDecodeError as e: logger.error(f"Error parsing result as JSON: {e}") return False except Exception as e: logger.error(f"Error: {e}", exc_info=True) return False async def main(): """Run all tests.""" logger.info("Running direct tests for Databricks MCP server") # Run tests success = await test_list_clusters() if success: logger.info("All tests passed!") return 0 else: logger.error("Tests failed") return 1 if __name__ == "__main__": sys.exit(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/samhavens/databricks-mcp-server'

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