test_mcp_simple.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python3
  2. """
  3. 简单测试MCP服务的API路径
  4. """
  5. import requests
  6. # MCP服务的基础URL
  7. BASE_URL = "http://localhost:18000"
  8. # 测试不同的API路径格式
  9. test_paths = [
  10. "/vectorize_store",
  11. "/tools/vectorize_store",
  12. "/mcp/tools/vectorize_store",
  13. "/api/vectorize_store",
  14. "/",
  15. "/docs",
  16. "/openapi.json"
  17. ]
  18. # 测试数据
  19. test_data = {
  20. "dataset_id": "test_dataset_001",
  21. "book_name": "测试书籍",
  22. "document_id": "test_doc_001",
  23. "parsed_results": [
  24. {
  25. "page_number": 1,
  26. "content": "这是测试书籍的第1页内容",
  27. "image_url": "https://example.com/image1.jpg"
  28. }
  29. ]
  30. }
  31. print("开始测试MCP服务的API路径...\n")
  32. for path in test_paths:
  33. url = f"{BASE_URL}{path}"
  34. print(f"测试路径: {url}")
  35. try:
  36. response = requests.post(url, json=test_data, timeout=5)
  37. print(f"状态码: {response.status_code}")
  38. print(f"响应内容: {response.text[:100]}...")
  39. except Exception as e:
  40. print(f"请求失败: {str(e)}")
  41. print("-" * 50)