Skip to main content
Glama

Obsidian MCP Server

by getglad
test_e2e.py3.71 kB
#!/usr/bin/env python3 """End-to-end test of Obsidian MCP server with real vault.""" import sys from pathlib import Path from dotenv import load_dotenv # Load environment variables load_dotenv() print("=" * 60) print("END-TO-END TEST: Obsidian MCP Server") print("=" * 60) # Test 1: Configuration loads print("\n[1/6] Testing configuration...") try: from obsidian_mcp.config import ObsidianConfig config = ObsidianConfig.from_env() print(f"✅ Config loaded successfully") print(f" Vault path: {config.vault_path}") print(f" Path exists: {config.vault_path.exists()}") print(f" Max results: {config.max_results}") print(f" Snippet length: {config.snippet_length}") except Exception as e: print(f"❌ Config failed: {e}") sys.exit(1) # Test 2: Vault initialization print("\n[2/6] Testing vault initialization...") try: from obsidian_mcp.vault import ObsidianVault vault = ObsidianVault(config) print(f"✅ Vault initialized successfully") except Exception as e: print(f"❌ Vault init failed: {e}") sys.exit(1) # Test 3: List notes print("\n[3/6] Testing list_notes...") try: notes = vault.list_notes(limit=10) print(f"✅ Found {len(notes)} notes (showing first 5):") for note in notes[:5]: print(f" - {note.name} ({note.size} bytes)") if note.tags: print(f" Tags: {', '.join(note.tags[:3])}") except Exception as e: print(f"❌ List notes failed: {e}") sys.exit(1) # Test 4: Read a note print("\n[4/6] Testing read_note...") try: if notes: test_note_path = notes[0].path note = vault.read_note(test_note_path) print(f"✅ Read note: {note.path}") print(f" Has frontmatter: {note.frontmatter is not None}") print(f" Content length: {len(note.content)} chars") print(f" First 100 chars: {note.body[:100]}...") else: print("⚠️ No notes to read (vault is empty)") except Exception as e: print(f"❌ Read note failed: {e}") sys.exit(1) # Test 5: Search functionality print("\n[5/6] Testing search...") try: from obsidian_mcp.search import VaultSearch search = VaultSearch(vault) # Search for common word results = search.search(query="the", search_type="content", limit=5) print(f"✅ Search for 'the' found {len(results)} results") if results: print(f" Top result: {results[0].name} (score: {results[0].score})") if results[0].snippet: print(f" Snippet: {results[0].snippet[:100]}...") except Exception as e: print(f"❌ Search failed: {e}") sys.exit(1) # Test 6: MCP Server tools print("\n[6/6] Testing MCP server tools...") try: from obsidian_mcp.server import read_note, search_notes, list_notes # Test list_notes tool result = list_notes(limit=5) print(f"✅ list_notes tool: {len(result)} chars of output") # Test search_notes tool result = search_notes(query="note", search_type="all", limit=3) print(f"✅ search_notes tool: {len(result)} chars of output") # Test read_note tool (if we have notes) if notes: result = read_note(path=notes[0].path) print(f"✅ read_note tool: {len(result)} chars of output") except Exception as e: print(f"❌ MCP tools failed: {e}") import traceback traceback.print_exc() sys.exit(1) print("\n" + "=" * 60) print("✅ ALL TESTS PASSED!") print("=" * 60) print(f"\nYour vault at {config.vault_path} is ready to use!") print(f"Total notes in vault: {len(vault.list_notes(limit=1000))}") print("\nNext steps:") print("1. Configure Claude Desktop (see README.md)") print("2. Or test with: npx @modelcontextprotocol/inspector")

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/getglad/obsidian_mcp'

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