Spaces:
Sleeping
Sleeping
| # mcp_server.py | |
| from fastmcp import FastMCP | |
| from huggingface_hub import ModelCard | |
| import json | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| mcp = FastMCP("model_card-chatbot") | |
| def read_model_card(repo_id: str) -> str: | |
| """ | |
| Tool to read and return the full model card from Hugging Face. | |
| """ | |
| try: | |
| card = ModelCard.load(repo_id) | |
| return json.dumps({"status": "success", "readme": card.text}) | |
| except FileNotFoundError: | |
| return json.dumps({"status": "error", "message": "This model does not have a model card"}) | |
| except Exception as e: | |
| return json.dumps({"status": "error", "message": str(e)}) | |