Skip to main content
Glama
usage_examples.py4.28 kB
""" MSI MCP Server Usage Examples This file demonstrates how to use the MSI MCP Server for various tasks. """ import json from mcp_msi_server import ( local_read_msi_metadata, local_suggest_silent_commands, local_get_product_code, local_build_install_command, local_build_uninstall_command, local_registry_list_installed, local_registry_find_by_name, local_list_features, local_list_shortcuts ) def example_basic_msi_reading(): """Example: Basic MSI metadata reading""" print("=== Basic MSI Reading ===") msi_path = r"C:\path\to\your\installer.msi" # Read metadata metadata = local_read_msi_metadata(msi_path) print("MSI Metadata:") print(json.dumps(metadata, indent=2, ensure_ascii=False)) # Get silent commands commands = local_suggest_silent_commands(msi_path) print("\nSilent Commands:") print(json.dumps(commands, indent=2, ensure_ascii=False)) def example_advanced_commands(): """Example: Building advanced install/uninstall commands""" print("\n=== Advanced Commands ===") msi_path = r"C:\path\to\your\installer.msi" # Build install command with logging install_cmd = local_build_install_command( msi_path, log_path="install.log", extra_args="ALLUSERS=1" ) print(f"Install Command: {install_cmd}") # Get product code and build uninstall command product_code = local_get_product_code(msi_path) uninstall_cmd = local_build_uninstall_command( product_code, log_path="uninstall.log" ) print(f"Uninstall Command: {uninstall_cmd}") def example_registry_queries(): """Example: Querying installed applications""" print("\n=== Registry Queries ===") # List all installed apps apps = local_registry_list_installed() print(f"Total installed apps: {len(apps)}") # Find specific app found_apps = local_registry_find_by_name("7-Zip") if found_apps: print(f"Found {len(found_apps)} 7-Zip installations:") for app in found_apps: print(f" - {app.get('DisplayName')} {app.get('DisplayVersion')}") else: print("No 7-Zip installations found") def example_msi_analysis(): """Example: Advanced MSI analysis""" print("\n=== MSI Analysis ===") msi_path = r"C:\path\to\your\installer.msi" try: # List features features = local_list_features(msi_path) print(f"MSI Features: {len(features)}") for feature in features[:3]: # Show first 3 print(f" - {feature.get('Feature')}: {feature.get('Title')}") # List shortcuts shortcuts = local_list_shortcuts(msi_path) print(f"\nMSI Shortcuts: {len(shortcuts)}") for shortcut in shortcuts[:3]: # Show first 3 print(f" - {shortcut.get('Name')} -> {shortcut.get('Target')}") except Exception as e: print(f"Advanced analysis error: {e}") def example_batch_processing(): """Example: Processing multiple MSI files""" print("\n=== Batch Processing ===") msi_files = [ r"C:\path\to\installer1.msi", r"C:\path\to\installer2.msi", r"C:\path\to\installer3.msi" ] results = [] for msi_path in msi_files: try: metadata = local_read_msi_metadata(msi_path) results.append({ 'file': msi_path, 'product': metadata.get('ProductName'), 'version': metadata.get('ProductVersion'), 'manufacturer': metadata.get('Manufacturer') }) except Exception as e: results.append({ 'file': msi_path, 'error': str(e) }) print("Batch Processing Results:") print(json.dumps(results, indent=2, ensure_ascii=False)) if __name__ == "__main__": print("MSI MCP Server Usage Examples") print("=" * 40) # Run examples (uncomment the ones you want to test) # example_basic_msi_reading() # example_advanced_commands() # example_registry_queries() # example_msi_analysis() # example_batch_processing() print("\nNote: Update the MSI file paths in the examples before running.")

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/henry1042/MSI-MCP-Server'

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