From huggingface-skills
Deploy/host an MCP server on Hugging Face Spaces. Use when the user wants to publish an MCP server on HF, turn a Gradio app or Python tools into an MCP server, package an existing (Node/Python/etc.) HTTP/SSE MCP server as a Space, or choose between the Gradio-native and Docker paths. Covers the non-obvious parts (transport, app_port routing, private-Space auth, secrets, bucket mounts, cold starts) and points to the official docs instead of duplicating them.
How this skill is triggered — by the user, by Claude, or both
Slash command
/huggingface-skills:deploy-mcp-server-on-hfThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Hugging Face **Spaces** are the way to host a long-running MCP server (Jobs are
Hugging Face Spaces are the way to host a long-running MCP server (Jobs are ephemeral; Inference Endpoints are model-oriented). There are two paths — pick by what the server is.
| Situation | Path |
|---|---|
| Python functions/tools you want exposed as MCP tools | A — Gradio Space (native MCP) |
| An existing MCP server, or non-Python (Node, Go…), or you need full control of the endpoint/transport | B — Docker Space |
| You just want an existing Gradio Space as a tool (not to host a server) | Don't deploy anything — proxy it via huggingface.co/mcp / hf-mcp-server (see Pointers) |
Hard rule for both: a Space is reached over HTTP, so the server must speak Streamable HTTP (preferred) or SSE (legacy). stdio does not work remotely.
Lowest effort for Python. Gradio turns decorated functions (their type hints + docstrings become the MCP tool schema) into MCP tools when you enable the MCP server.
requirements.txt includes gradio[mcp].demo.launch(mcp_server=True) (or env GRADIO_MCP_SERVER=true).The MCP endpoint is published by Gradio (path + SSE/Streamable-HTTP details are in the guide). Do not re-derive these steps — follow the canonical guide:
For an existing/other-language MCP server. This generic path is not written up as an MCP guide, so the concrete recipe + gotchas live in references/docker-space-mcp.md. Base Spaces docs: https://huggingface.co/docs/hub/spaces-sdks-docker and the config reference: https://huggingface.co/docs/hub/spaces-config-reference
The parts that bite (covered in the reference):
app_port in the Space README.md metadata MUST match the port your
server listens on (HF routes external traffic there; default is 7860). This
is the #1 reason a deploy "builds but won't connect".0.0.0.0, not localhost.Authorization: Bearer <hf_token>; or use "Sign in with HF" OAuth.hf spaces volumes set … -v hf://buckets/<ns>/<bucket>:/mnt/…:ro).sleep_time or
use paid hardware; the first request after sleep is slow.https://<user>-<space>.hf.space/<mcp-endpoint>.initialize POST (curl/Python) and confirm
serverInfo + the capabilities you expect; for a private Space include the
Authorization: Bearer header. Or use the MCP Inspector, or point a real
client (Claude Desktop config, fast-agent, etc.).fast-agent go consumes tools only) — test with a
client that exercises the surface you care about.npx claudepluginhub olaservo/huggingface-skills --plugin train-sentence-transformersGuides reception of code review feedback: verify before implementing, avoid performative agreement, push back with technical reasoning when needed.
Design banners for social media, ads, website heroes, and print with multiple art direction options and AI-generated visuals.