Model Picker
A command-line example that turns a plain-language task into a shortlist of open models, with one recommendation and the evidence behind it. You describe what you need -"on-device English speech-to-text, small enough to run on a laptop" - and the model returns a table of real Hugging Face repos plus a pick you can defend.
It does this with one Agent API request that combines two tools.
The mcp tool connects the model to the Hugging Face MCP server, so it can search the live model registry and read each repo’s real metadata.
The web_search tool lets it check benchmarks, quality, and known issues in the same run.
The Hub says which models exist and how they are adopted and licensed; the web says whether they are any good.
Neither tool alone is enough.
What MCP does here
- Gives the model live registry facts. The
mcptool lets it callhub_repo_searchandhub_repo_detailsto pull the models that exist right now, with their real download counts, licenses, and last-modified dates. - No integration code on your side. Agent API discovers the server’s tools when the request starts and calls them like native tools. You point the
mcptool at the server URL - there is no Hugging Face SDK to install, no endpoints to wrap, no schema to maintain. - Read-only by design. The example allow-lists the Hub’s read tools (
hub_repo_search,hub_repo_details,paper_search,hf_doc_search,hf_doc_fetch) withallowed_tools, so the model can look up models but nothing else.
Without MCP
Ask a plain chat model to pick a model and it answers from training data: it names repos it remembers, guesses at download counts, and cannot tell you what shipped last month or whether a license changed. The alternative is to do it by hand: query the Hugging Face API for candidates, then fetch, rank, and cross-check each one against the web yourself. Themcp tool and web_search do that whole job inside the one request above.
Installation
Keepmodel_picker.py and requirements.txt in the same directory.
- Install the Perplexity Python SDK, pinned in
requirements.txt:
requirements.txt
- Set your Perplexity API key:
https://huggingface.co/mcp) needs no key - the example connects to it anonymously.
- (Optional) Raise the Hugging Face rate limit. Anonymous access to the MCP server is rate-limited. For heavier use, create a Hugging Face token (a read token is enough) and export it as
HF_TOKEN:
mcp tool’s authorization field. Leave it unset to run anonymously.
The
mcp tool is in preview and needs Agent API access - see the MCP docs for current availability.Usage
Pass the task as a single argument:--show-tools to also print the tool calls the model made, in order, so you can see the Hub lookups and the web searches that produced the answer.
How it works
The whole run is a singleclient.responses.create call given two tools - the Hugging Face mcp server and web_search - and one instruction: ground every claim in the tools.
That instruction is the point of the example.
Without it, the model treats the tools as optional and skips them.
The system prompt closes that door: it makes the model verify each candidate against the Hub and the web before it recommends anything.
In practice, the run has two phases.
First, the model narrows the field on the Hub, refining its search several times and then reading the repo details of the finalists.
Then it switches to the web to check how good those finalists actually are, and only then writes the shortlist and its pick.
See the tool calls (--show-tools)
See the tool calls (--show-tools)
In the trace, Hugging Face MCP calls appear as The model writes these queries itself and refines them between calls, so the exact shape varies from run to run.
mcp:<tool>; the Agent API’s web searches appear as web_search with the queries it ran.
On the run below, the model searched the Hub seven times, read the finalists’ details once, then ran a round of web search before answering - Hub first, web second.Full code
The script is one file: build the two tools, submit one background request, poll until it finishes, and print the answer (plus an optional tool trace).Full code - model_picker.py
Full code - model_picker.py
model_picker.py
Example Output
A real run -python model_picker.py "on-device English speech-to-text, small enough to run on a laptop" (results vary with the live Hub and web):
Limitations
- Live variance. The shortlist depends on the live Hub and current web results, so the exact models and the recommendation can differ between runs.
- Anonymous rate limits. The example connects to the Hugging Face MCP server anonymously, which is rate-limited. For heavier use, set
HF_TOKEN(see Installation) to authenticate and raise the limit. - Third-party servers. Remote MCP servers are third-party services - connect only servers you trust. See Risks and safety.