TLDRocket
Sign in

Tiny Agents in Python: a MCP-powered agent in ~70 lines of code

Hugging Face

Hugging Face ported its Tiny Agents concept to Python, letting you build an MCP-connected AI agent in about 70 lines of code. It turns tool-calling for LLMs into a plug-and-play loop instead of custom integrations for every API.

Based on reporting by Hugging Face — read the original for the full story.

Summary, retelling and take written by AI under human oversight; images are AI-generated illustrations. How we work · Report an error

Hugging Face just dropped a Python version of Tiny Agents, following up on the JavaScript take from earlier this year. The pitch is almost aggressively simple: an AI agent is basically a while loop sitting on top of an MCP client, and now that client lives directly inside huggingface_hub. Install the package with the mcp extra, run one CLI command, and you've got a working agent pulling tools from Model Context Protocol servers without writing a single custom API wrapper.

MCP itself is the interesting part here, more than the Python wrapper. It's an open protocol that standardizes how LLMs talk to external tools, so instead of hand-rolling integrations for a file system, a browser, or an image generator, you point the agent at an MCP server and it discovers what's available on its own. Hugging Face's demos show this off nicely: a Qwen2.5-72B model running through Nebius can drive a sandboxed Chromium browser via the Playwright MCP server, search Brave, open a page, and summarize inference providers back to you. Another demo swaps in a FLUX.1 schnell Space as an MCP server and generates a 1024x1024 image of an astronaut hatching from an egg on the moon, just from a text prompt.

Under the hood, the new MCPClient class does the heavy lifting: it manages async connections to multiple MCP servers over stdio, SSE, or HTTP, lists their tools, formats them into the same JSON schema OpenAI's Chat Completions API expects, and executes whichever tool the model decides to call. The streaming loop is genuinely tidy — chunks come back from the LLM, get reassembled into text and tool calls, and once a tool call is complete, the client finds the right MCP session and fires it off, feeding the result straight back into the conversation.

What's left for the Agent class itself is almost embarrassingly small. It just initializes a system prompt, loads MCP servers from a config file, and loops: call the LLM, check if a tool got invoked, execute it, repeat until an exit condition trips, whether that's an explicit exit-loop tool, a turn limit, or the model deciding it's done. Configuration lives in a single agent.json specifying the model, provider, and which MCP servers to spin up, with an optional PROMPT.md for anything more elaborate than the default system prompt.

The timing lines up with the newly added support for the AGENTS.md standard, another sign that Hugging Face wants Tiny Agents to be less of a demo and more of a reusable pattern people actually build on. Given how much boilerplate MCP removes, that's not an unreasonable bet.

My take — AI-written commentary, not fact-checked reporting

This is the kind of unglamorous plumbing work that actually moves the ecosystem forward — MCP is quietly becoming the USB-C of tool calling, and Hugging Face wiring it straight into huggingface_hub means fewer people reinventing bespoke tool integrations badly. My only gripe is that demos like 'browse the web and summarize a page' still feel like party tricks rather than proof these loops are reliable at scale; I'd rather see benchmarks on tool-call accuracy than another moon-astronaut image.

Read more about this at: Hugging Face

Related stories

The daily briefing

Every AI story that matters, in your inbox by 8am.

TLDRocket reads all relevant sources, removes duplicate coverage, and summarises the day in two minutes. Follow companies and topics for alerts, or get the briefing in Slack. Free, no spam, unsubscribe anytime.