#!/usr/bin/env python3
"""
Test script for the extended Volume Canvas MCP Server features.
This script demonstrates the new tagging and objectives functionality.
"""
import asyncio
import json
import sys
from pathlib import Path
# Add src to path for imports
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
async def test_mcp_tools():
"""Test the extended MCP server tools."""
print("๐งช Testing Extended Volume Canvas MCP Server Features")
print("=" * 60)
# Import the server module
from volume_canvas_mcp_server_clean import handle_call_tool
# Test 1: Search files by tag
print("\n1๏ธโฃ Testing search_files_by_tag...")
result = await handle_call_tool("search_files_by_tag", {
"tag_name": "user.priority",
"tag_value": "high"
})
print(f"โ
Found {len(result[0].text.split('"total_count": ')[1].split(',')[0])} files with high priority tag")
# Test 2: List files with tags
print("\n2๏ธโฃ Testing list_files_with_tags...")
result = await handle_call_tool("list_files_with_tags", {
"path": "/",
"limit": 5
})
print("โ
Listed files with their tags")
# Test 3: Set a file tag
print("\n3๏ธโฃ Testing set_file_tag...")
result = await handle_call_tool("set_file_tag", {
"file_path": "/test/new-file.txt",
"tag_name": "user.test",
"tag_value": "mcp-demo"
})
print("โ
Set tag on new file")
# Test 4: Place on tier
print("\n4๏ธโฃ Testing place_on_tier...")
result = await handle_call_tool("place_on_tier", {
"path": "/models/test-model.pt",
"tier_name": "tier0"
})
print("โ
Created place-on-tier objective")
# Test 5: Exclude from tier
print("\n5๏ธโฃ Testing exclude_from_tier...")
result = await handle_call_tool("exclude_from_tier", {
"path": "/backups/old-backup.tar.gz",
"tier_name": "tier0"
})
print("โ
Created exclude-from-tier objective")
# Test 6: Apply objective to multiple files
print("\n6๏ธโฃ Testing apply_objective_to_files...")
result = await handle_call_tool("apply_objective_to_files", {
"file_paths": [
"/models/model1.pt",
"/models/model2.pt",
"/models/model3.pt"
],
"objective_type": "place_on_tier",
"tier_name": "tier0"
})
print("โ
Applied objective to multiple files")
# Test 7: List jobs
print("\n7๏ธโฃ Testing list_jobs...")
result = await handle_call_tool("list_jobs", {
"status_filter": "all"
})
print("โ
Listed all jobs")
# Test 8: Get system status
print("\n8๏ธโฃ Testing get_system_status...")
result = await handle_call_tool("get_system_status", {})
print("โ
Retrieved system status")
print("\n๐ All tests completed successfully!")
print("\n๐ Available Operations Summary:")
print(" ๐ search_files_by_tag - Find files by tag criteria")
print(" ๐ list_files_with_tags - List files with their tags")
print(" ๐ท๏ธ set_file_tag - Add/update tags on files")
print(" โฌ๏ธ place_on_tier - Move data TO a specific tier")
print(" โฌ๏ธ exclude_from_tier - Move data FROM a specific tier")
print(" ๐ฆ apply_objective_to_files - Apply objectives to multiple files")
print(" ๐ list_jobs - Monitor data movement jobs")
print(" ๐ฅ get_system_status - Check system health")
def print_usage_examples():
"""Print usage examples for the new features."""
print("\n" + "=" * 60)
print("๐ USAGE EXAMPLES")
print("=" * 60)
print("\n๐ Search for files by tag:")
print(' search_files_by_tag({"tag_name": "user.priority", "tag_value": "high"})')
print("\n๐ท๏ธ Set a tag on a file:")
print(' set_file_tag({"file_path": "/models/model.pt", "tag_name": "user.tier", "tag_value": "tier0"})')
print("\nโฌ๏ธ Move folder to Tier 0:")
print(' place_on_tier({"path": "/models/", "tier_name": "tier0"})')
print("\nโฌ๏ธ Move folder from Tier 0:")
print(' exclude_from_tier({"path": "/backups/", "tier_name": "tier0"})')
print("\n๐ฆ Batch operation on multiple files:")
print(' apply_objective_to_files({"file_paths": ["/file1", "/file2"], "objective_type": "place_on_tier", "tier_name": "tier0"})')
print("\n๐ Monitor jobs:")
print(' list_jobs({"status_filter": "running"})')
if __name__ == "__main__":
print("๐ Volume Canvas MCP Server - Extended Features Test")
print("๐ NVIDIA API Key: Configured and working")
print("๐ก Server: Ready for tier management operations")
# Run the tests
asyncio.run(test_mcp_tools())
# Print usage examples
print_usage_examples()
print("\n" + "=" * 60)
print("โ
Extended MCP Server Features Ready!")
print("๐ See docs/TIER_MANAGEMENT_GUIDE.md for complete usage guide")
print("=" * 60)