#!/usr/bin/env python3
"""Quick SASS test to see what's failing."""

import asyncio
import json
from pathlib import Path
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client


async def test_sass():
    server_script = Path(__file__).parent / "start_mcp_server.py"
    server_params = StdioServerParameters(
        command="python",
        args=[str(server_script)],
        env=None,
    )
    
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()
            
            print("Testing SASS query...")
            
            try:
                result = await session.call_tool("sass_query", {
                    "query": "test query"
                })
                
                print(f"Result type: {type(result)}")
                print(f"Content type: {type(result.content[0])}")
                print(f"Text content: {result.content[0].text[:500]}")
                
                parsed = json.loads(result.content[0].text)
                print("SUCCESS! Parsed JSON:")
                print(json.dumps(parsed, indent=2))
                
            except Exception as e:
                print(f"ERROR: {type(e).__name__}: {e}")
                if hasattr(e, 'args'):
                    print(f"Args: {e.args}")


if __name__ == "__main__":
    asyncio.run(test_sass())
