You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
2.1 KiB

#!/usr/bin/env python3
"""
Quick test script for MCP server tools.
Run: python test_tools.py
"""
import asyncio
import json
from pprint import pprint
from mcp_server import tools
async def main():
print("🔍 Testing MCP server tools...\n")
# 1. Ping (simulated, since it's just "ok")
print("1 ping → ok")
print("", "ok\n")
# 2. Search documents with a trivial AQL (read-only)
try:
aql = "FOR d IN riksdagen LIMIT 1 RETURN d"
print("2 search_documents...")
result = await asyncio.to_thread(tools.search_documents, aql)
print(" ✅ rows:", result["row_count"])
except Exception as e:
print(" ❌ search_documents failed:", e)
print()
# 3. Run AQL query directly
try:
aql = "FOR d IN riksdagen LIMIT 1 RETURN d"
print("3 run_aql_query...")
rows = await asyncio.to_thread(tools.run_aql_query, aql)
print(" ✅ got", len(rows), "rows")
except Exception as e:
print(" ❌ run_aql_query failed:", e)
print()
# 4. Vector search (Chroma)
try:
print("4 vector_search_talks...")
hits = await asyncio.to_thread(tools.vector_search, "klimatpolitik", 3)
print(f" ✅ got {len(hits)} hits")
if hits:
print("", hits[0])
except Exception as e:
print(" ❌ vector_search_talks failed:", e)
print()
# 5. Fetch documents
try:
print("5 fetch_documents (demo id)...")
# Adjust a known _id if needed; using a dummy for now
docs = await asyncio.to_thread(tools.fetch_documents, ["riksdagen/1"])
print(" ✅ got", len(docs), "docs")
except Exception as e:
print(" ❌ fetch_documents failed:", e)
print()
# 6. Arango search
try:
print("6 arango_search...")
result = await asyncio.to_thread(tools.arango_search, "budget", 3)
print(" ✅ got", len(result.get("results", [])), "hits")
except Exception as e:
print(" ❌ arango_search failed:", e)
print()
print("🏁 Done.\n")
if __name__ == "__main__":
asyncio.run(main())