
Hugging Face Blog
· 2 min read
Tiny Agents: an MCP-powered agent in 50 lines of code
New! (May 23, '25) If you prefer Python, check out the companion post Tiny Agents in Python.
Over the past few weeks, I've been diving into MCP (Model Context Protocol) to understand what the hype around it was all about.
My TL;DR is that it's fairly simple, but still quite powerful: MCP is a standard API to expose sets of Tools that can be hooked to LLMs.
It is fairly simple to extend an Inference Client – at HF, we have two official client SDKs: @huggingface/inference in JS, and huggingface_hub in Python – to also act as a MCP client and hook the available tools from MCP servers into the LLM inference.
But while doing that, came my second realization:
Once you have an MCP Client, an Agent is literally just a while loop on top of it.
In this short article, I will walk you through how I implemented it in Typescript (JS), how you can adopt MCP too and how it's going to make Agentic AI way simpler going forward.
How to run the complete demo
If you have NodeJS (with pnpm or npm), just run this in a terminal:
npx @huggingface/mcp-client
or if using pnpm:
pnpx @huggingface/mcp-client
This installs my package into a temporary folder then executes its command.
You'll see your simple Agent connect to two distinct MCP servers (running locally), loading their tools, then prompting you for a conversation.
By default our example Agent connects to the following two MCP servers:
- the "canonical" file system server, which gets access to your Desktop,
- and the Playwright MCP server, which knows how to use a sandboxed Chromium browser for you.
Note: this is a bit counter-intuitive but currently, all MCP servers are actually local processes (though remote servers are coming soon).
Our input for this first video was:
write a haiku about the Hugging Face community and write it to a file named "hf.txt" on my Desktop
Now let us try this prompt that involves some Web browsing:
do a Web Search for HF inference providers on Brave Search and open the first 3 results
Original source
This story was published by Hugging Face Blog. SyncAI.news shows a preview; the complete article is on the publisher's site.
Read the full story on huggingface.co


