| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #!/usr/bin/env python3
- """
- 简单测试MCP服务的API路径
- """
- import requests
- # MCP服务的基础URL
- BASE_URL = "http://localhost:18000"
- # 测试不同的API路径格式
- test_paths = [
- "/vectorize_store",
- "/tools/vectorize_store",
- "/mcp/tools/vectorize_store",
- "/api/vectorize_store",
- "/",
- "/docs",
- "/openapi.json"
- ]
- # 测试数据
- test_data = {
- "dataset_id": "test_dataset_001",
- "book_name": "测试书籍",
- "document_id": "test_doc_001",
- "parsed_results": [
- {
- "page_number": 1,
- "content": "这是测试书籍的第1页内容",
- "image_url": "https://example.com/image1.jpg"
- }
- ]
- }
- print("开始测试MCP服务的API路径...\n")
- for path in test_paths:
- url = f"{BASE_URL}{path}"
- print(f"测试路径: {url}")
- try:
- response = requests.post(url, json=test_data, timeout=5)
- print(f"状态码: {response.status_code}")
- print(f"响应内容: {response.text[:100]}...")
- except Exception as e:
- print(f"请求失败: {str(e)}")
- print("-" * 50)
|