Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 16 min read How-to mediumAdept

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

Hugging Face's huggingface_hub Python SDK now includes an MCP client and a minimal Agent class, letting an LLM pull tools from MCP servers (stdio, SSE or streamable HTTP) and call them during inference. Install it with `pip install "huggingface_hub[mcp]"`, then run agents from the `tiny-agents` CLI, configured by an agent.json that sets model, inference provider and MCP servers, plus an optional PROMPT.md. The MCPClient connects to servers, converts their tool schemas into OpenAI-style function definitions, and streams chat completions while rebuilding tool calls. It then routes each call to the right MCP session. The Agent is essentially a while loop on top of the client, with special exit-loop tools to end a turn.

Related posts

  • Tiny Agents: an MCP-powered agent in 50 lines of code

    Hugging Face mediumAdept

    An LLM agent built on the Model Context Protocol reduces to a simple while loop around an MCP-aware inference client: connect to MCP servers, convert their tools into OpenAI-style function definitions, pass them to the chat-completion call, execute returned tool calls via the MCP SDK, and feed results back. The TypeScript implementation in huggingface.js extends InferenceClient into an McpClient that holds one session per server and maps tool names to sessions. An Agent class adds a system prompt plus two control-flow tools (task_complete, ask_question). The loop alternates tool calls and results until an exit tool is called, the model answers twice without tools, or a turn limit is reached. The default setup uses Qwen2.5-72B on Nebius, and the model, provider and MCP servers can be swapped.

  • Implementing MCP Servers in Python: An AI Shopping Assistant with Gradio

    Hugging Face mediumAdept

    Gradio's MCP integration turns Python functions into LLM tools: launching an app with mcp_server=True exposes each endpoint as an MCP tool, with names, descriptions and input schemas generated from function docstrings, plus progress streaming and file upload handling. The walkthrough builds a virtual try-on shopping assistant by wrapping the IDM-VTON diffusion Space, called through the Gradio API client, in a Gradio Interface. That server is registered alongside the Playwright MCP server in VS Code's mcp.json, so the AI chat can browse a clothing store and render the user wearing selected garments.

  • Tool Use, Unified

    Hugging Face mediumAdept

    Hugging Face Transformers extends Jinja chat templates to cover tool use, giving a single portable API for passing tools to Mistral, Cohere, NousResearch and Llama models. Tools are defined as JSON schema, or as Python functions whose type hints and docstrings are converted automatically via get_json_schema. Tool calls go into the chat as a tool_calls field on assistant messages, and results are added as separate tool-role messages. A full walkthrough with Hermes-2-Pro-Llama-3-8B shows the loop end to end. Parsing the model's emitted tool-call text is still model-specific and needs a little json.loads or regex work.

  • Introducing Agents.js: Give tools to your LLMs using JavaScript

    Hugging Face mediumAdept

    Agents.js is a JavaScript library from huggingface.js that gives LLMs tool access in the browser or on Node. An HfAgent turns a plain-text command into JavaScript that chains multimodal tools such as textToImage, imageToText and textToSpeech, then evaluates that code and returns messages carrying strings or Blobs. Any async string-to-string function can stand in as the LLM, with OpenAI shown as an example, and custom tools are defined with a name, description, few-shot examples and a call function. Because the agent executes arbitrary generated code, generateCode followed by evaluateCode is recommended over run, so the code can be reviewed before it executes.

  • How to build AI agents with MCP: 12 framework comparison (2025)

    ClickHouse mediumAdept

    Twelve agent SDKs now support the Model Context Protocol: Claude Agent SDK, OpenAI Agents SDK, Microsoft Agent Framework, Google ADK, CrewAI, Upsonic, mcp-agent, Agno, DSPy, LangChain, LlamaIndex and PydanticAI. Each is shown connecting to the ClickHouse MCP Server against a public SQL playground, with Python code for every framework. Differences covered include Claude Agent SDK's required tool allowlist, OpenAI's handoff and streaming patterns, and Microsoft's preview status and Azure ties. Choosing among them comes down to language support, ecosystem and how much abstraction you want.

The quest for software engineering knowledge.

Look:
Layout: