Skip to content

Instantly share code, notes, and snippets.

@Wauplin
Wauplin / hf_mcp.py
Created May 6, 2025 16:28
Python-based HF MCP server
"""
WARNING: This is an experimental implementation. Expect rough edges while using it.
-------------------------------------------------
Defines a FastMCP server that exposes the Hugging Face Hub API as a set of tools.
In practice, all public methods from `HfApi` are exposed as tools, except for the ones dealing with files:
- `create_commit`
- `hf_hub_download`
- `preupload_lfs_files`
@Wauplin
Wauplin / syncify_test.py
Created June 28, 2023 08:42
Test syncify-like decorator to define both a Sync and Async client
import asyncio
import functools
from typing import Callable, Coroutine, Any, TypeVar, ParamSpec
T_Retval = TypeVar("T_Retval")
T_ParamSpec = ParamSpec("T_ParamSpec")
def syncify(async_function: Callable[T_ParamSpec, Coroutine[Any, Any, T_Retval]]) -> Callable[T_ParamSpec, T_Retval]:
# Taken from https://github.com/tiangolo/asyncer and simplified