Connecting Claude to Tinderbox using MCP

Forgot the server set up script

I have Claude connected to both my obsidian vault and which ever Tinderbox document I have open

#!/usr/bin/env python3
"""
Test script for Tinderbox MCP Server
Run this to verify your setup is working correctly
"""

import subprocess
import sys

print("Starting Tinderbox MCP Server...", file=sys.stderr)
print(f"Python version: {sys.version}", file=sys.stderr)
print("Imports successful", file=sys.stderr)

def run_applescript(script):
    """Execute AppleScript and return result"""
    try:
        result = subprocess.run(
            ['osascript', '-e', script],
            capture_output=True,
            text=True,
            check=True
        )
        return True, result.stdout.strip()
    except subprocess.CalledProcessError as e:
        return False, e.stderr.strip()

def test_tinderbox_connection():
    """Test basic Tinderbox connectivity"""
    print("🔍 Testing Tinderbox MCP Connection...\n")
    
    # Test 1: Check if Tinderbox is running
    print("1. Checking if Tinderbox is running...")
    script = '''
    tell application "System Events"
        return exists (process "Tinderbox 10")
    end tell
    '''
    success, result = run_applescript(script)
    
    if not success or result != "true":
        print("❌ Tinderbox 10 is not running. Please start Tinderbox and try again.")
        return False
    print("✅ Tinderbox is running")
    
    # Test 2: Check if there's an open document
    print("\n2. Checking for open Tinderbox document...")
    script = '''
    tell application "Tinderbox 10"
        return (count of documents) > 0
    end tell
    '''
    success, result = run_applescript(script)
    
    if not success or result != "true":
        print("❌ No Tinderbox document is open. Please open a document and try again.")
        return False
    print("✅ Found open document")
    
    # Test 3: Try to read document name
    print("\n3. Testing document access...")
    script = '''
    tell application "Tinderbox 10"
        return name of front document
    end tell
    '''
    success, result = run_applescript(script)
    
    if not success:
        print(f"❌ Cannot access document: {result}")
        print("\n⚠️  You may need to grant Terminal permission to control Tinderbox:")
        print("   1. Go to System Settings → Privacy & Security → Accessibility")
        print("   2. Click the lock and enter your password")
        print("   3. Add and check Terminal (or Python)")
        return False
    
    print(f"✅ Successfully accessed document: {result}")
    
    # Test 4: Try to create a test note
    print("\n4. Testing note creation...")
    script = '''
    tell application "Tinderbox 10"
        tell front document
            set testNote to make new note
            set value of attribute "Name" of testNote to "MCP Test Note"
            set value of attribute "Text" of testNote to "This is a test note created by the MCP test script. You can delete this."
            return value of attribute "ID" of testNote
        end tell
    end tell
    '''
    success, result = run_applescript(script)
    
    if not success:
        print(f"❌ Cannot create note: {result}")
        return False
    
    print("✅ Successfully created test note")
    
    # Test 5: Try to read the test note back
    print("\n5. Testing note reading...")
    script = '''
    tell application "Tinderbox 10"
        tell front document
            set testNote to note "MCP Test Note"
            return value of attribute "Text" of testNote
        end tell
    end tell
    '''
    success, result = run_applescript(script)
    
    if not success:
        print(f"❌ Cannot read note: {result}")
        return False
    
    print("✅ Successfully read note content")
    
    # Test 6: Clean up - delete test note
    print("\n6. Cleaning up test note...")
    script = '''
    tell application "Tinderbox 10"
        tell front document
            set testNote to note "MCP Test Note"
            delete testNote
            return "deleted"
        end tell
    end tell
    '''
    success, result = run_applescript(script)
    
    if success:
        print("✅ Test note deleted")
    else:
        print("⚠️  Could not delete test note (you can delete it manually)")
    
    return True

def test_python_setup():
    """Test Python environment setup"""
    print("\n📦 Checking Python setup...\n")
    
    # Check Python version
    print(f"Python version: {sys.version}")
    
    # Check if MCP is installed
    try:
        import mcp
        print("✅ MCP SDK is installed")
        return True
    except ImportError:
        print("❌ MCP SDK is not installed")
        print("\nTo install it, run this command in Terminal:")
        print("   python3 -m pip install mcp")
        return False

def main():
    print("=" * 50)
    print("Tinderbox MCP Server Test")
    print("=" * 50)
    
    # Test Python setup
    if not test_python_setup():
        print("\n❌ Please install the MCP SDK first")
        return
    
    print("\n" + "=" * 50)
    
    # Test Tinderbox connection
    if test_tinderbox_connection():
        print("\n" + "=" * 50)
        print("✅ All tests passed! Your Tinderbox MCP setup is working correctly.")
        print("\nNext steps:")
        print("1. Make sure claude_desktop_config.json is configured")
        print("2. Run the server with: python3 tinderbox_mcp_server.py")
        print("3. Restart Claude Desktop")
        print("4. Try asking Claude to work with your Tinderbox notes!")
    else:
        print("\n" + "=" * 50)
        print("❌ Some tests failed. Please fix the issues above and try again.")

if __name__ == "__main__":
    main()
    input("\nPress Enter to close...")



4 Likes