Skip to main content
Glama
mve_example.py•3.05 kB
#!/usr/bin/env python3 """ Example script demonstrating how to use the MVE client with configuration-based credentials. This script shows how to access materialized view data without hardcoded credentials. """ import sys import os sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src')) from ssb_mcp_server.config import ServerConfig from ssb_mcp_server.mve_client import MVEClient import json def main(): """Example usage of MVE client with configuration-based credentials.""" print("šŸ”§ MVE API Example with Configuration-Based Credentials") print("=" * 60) try: # Load configuration from JSON file or environment variables config = ServerConfig.from_json_file() print(f"āœ… Configuration loaded successfully") print(f" MVE API Base: {config.get_mve_api_base()}") print(f" MVE Username: {config.mve_username}") print(f" MVE Password: {'*' * len(config.mve_password) if config.mve_password else 'Not set'}") # Create MVE client mve_client = MVEClient(config) print(f"āœ… MVE client created successfully") # Example: Query a materialized view # Replace with actual job ID and MV name from your environment job_id = 5202 # Example job ID mv_name = "MVTest1" # Example MV name print(f"\\nšŸ” Querying Materialized View:") print(f" Job ID: {job_id}") print(f" MV Name: {mv_name}") result = mve_client.query_materialized_view(job_id, mv_name, limit=10) print(f"\\nšŸ“Š Query Result:") print(f" Status: {result['status']}") if result['status'] == 'success': print(f" Record Count: {result['record_count']}") print(f" Data: {json.dumps(result['data'], indent=2)}") else: print(f" Error: {result['error_message']}") # Example: List materialized views for a job print(f"\\nšŸ“‹ Listing Materialized Views for Job {job_id}:") mvs_result = mve_client.list_materialized_views(job_id) print(f" Status: {mvs_result['status']}") if mvs_result['status'] == 'success': print(f" MVs: {json.dumps(mvs_result['data'], indent=2)}") else: print(f" Error: {mvs_result['error_message']}") except ValueError as e: print(f"āŒ Configuration Error: {e}") print("\\nšŸ’” To fix this, either:") print(" 1. Set environment variables:") print(" export MVE_API_BASE='your_mve_api_base'") print(" export MVE_USERNAME='your_username'") print(" export MVE_PASSWORD='your_password'") print(" 2. Or update config/cloud_ssb_config.json with MVE credentials") except Exception as e: print(f"āŒ Error: {e}") import traceback traceback.print_exc() print("\\nāœ… Example completed!") if __name__ == "__main__": 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/BrooksIan/SSB-MCP-Server'

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