mcp search online secondme model (#242)

This commit is contained in:
doubleBlack2 2025-04-24 14:24:45 +08:00 committed by GitHub
parent 9fe511f0f2
commit 516843d963
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 26 additions and 0 deletions

View File

@ -2,6 +2,7 @@ from typing import Any
from mcp.server.fastmcp import FastMCP
import http.client
import json
import requests
mindverse = FastMCP("mindverse_public")
url = "app.secondme.io"
@ -66,6 +67,31 @@ async def get_response(query:str, instance_id:str) -> str | None:
else:
return None
@mindverse.tool()
async def get_online_instances():
"""
Check which secondme models are available for chatting online.
"""
url = "https://app.secondme.io/api/upload/list?page_size=100"
response = requests.get(url)
if response.status_code == 200:
data = response.json()
items = data.get("data", {}).get("items", [])
online_items = [
{
"upload_name": item["upload_name"],
"instance_id": item["instance_id"],
"description": item["description"]
}
for item in items if item.get("status") == "online"
]
return json.dumps(online_items, ensure_ascii=False, indent=2)
else:
raise Exception(f"Request failed with status code: {response.status_code}")
if __name__ == "__main__":
mindverse.run(transport='stdio')