Now that we’ve built MCP servers in Gradio and learned about creating MCP clients, let’s complete our end-to-end application by building an agent that can seamlessly interact with our sentiment analysis tool. This section builds on the project Tiny Agents, which demonstrates a super simple way of deploying MCP clients that can connect to services like our Gradio sentiment analysis server.
In this final exercise of Unit 2, we will walk you through how to implement both TypeScript (JS) and Python MCP clients that can communicate with any MCP server, including the Gradio-based sentiment analysis server we built in the previous sections. This completes our end-to-end MCP application flow: from building a Gradio MCP server exposing a sentiment analysis tool, to creating a flexible agent that can use this tool alongside other capabilities.
![]()
Let’s install the necessary packages to build our Tiny Agents.
Some MCP Clients, notably Claude Desktop, do not yet support SSE-based MCP Servers. In those cases, you can use a tool such as mcp-remote. First install Node.js. Then, add the following to your own MCP Client config:
Tiny Agent can run MCP servers with a command line environment. To do this, we will need to install npm and run the server with npx. We’ll need these for both Python and JavaScript.
Let’s install npx with npm. If you don’t have npm installed, check out the npm documentation.
# install npx
npm install -g npxThen, we need to install the mcp-remote package.
npm i mcp-remote
For JavaScript, we need to install the tiny-agents package.
npm install @huggingface/tiny-agents
Let’s repeat the example from Unit 1 to create a basic Tiny Agent. Tiny Agents can create MCP clients from the command line based on JSON configuration files.
Let’s setup a project with a basic Tiny Agent.
mkdir my-agent
touch my-agent/agent.jsonThe JSON file will look like this:
{
"model": "Qwen/Qwen2.5-72B-Instruct",
"provider": "nebius",
"servers": [
{
"type": "stdio",
"config": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:7860/gradio_api/mcp/sse" // This is the MCP Server we created in the previous section
]
}
}
]
}We can then run the agent with the following command:
npx @huggingface/tiny-agents run ./my-agent
Here we have a basic Tiny Agent that can connect to our Gradio MCP server. It includes a model, provider, and a server configuration.
| Field | Description |
|---|---|
model | The open source model to use for the agent |
provider | The inference provider to use for the agent |
servers | The servers to use for the agent. We’ll use the mcp-remote server for our Gradio MCP server. |
We could also use an open source model running locally with Tiny Agents. If we start a local inference server with
{
"model": "Qwen/Qwen3-32B",
"endpointUrl": "http://localhost:1234/v1",
"servers": [
{
"type": "stdio",
"config": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:1234/v1/mcp/sse"
]
}
}
]
}Here we have a Tiny Agent that can connect to a local model. It includes a model, endpoint URL (http://localhost:1234/v1), and a server configuration. The endpoint should be an OpenAI-compatible endpoint.
Now that we understand both Tiny Agents and Gradio MCP servers, let’s see how they work together! The beauty of MCP is that it provides a standardized way for agents to interact with any MCP-compatible server, including our Gradio-based sentiment analysis server from earlier sections.
To connect our Tiny Agent to the Gradio sentiment analysis server we built earlier in this unit, we just need to add it to our list of servers. Here’s how we can modify our agent configuration:
const agent = new Agent({
provider: process.env.PROVIDER ?? "nebius",
model: process.env.MODEL_ID ?? "Qwen/Qwen2.5-72B-Instruct",
apiKey: process.env.HF_TOKEN,
servers: [
// ... existing servers ...
{
command: "npx",
args: [
"mcp-remote",
"http://localhost:7860/gradio_api/mcp/sse" // Your Gradio MCP server
]
}
],
});Now our agent can use the sentiment analysis tool alongside other tools! For example, it could:
When deploying your Gradio MCP server to Hugging Face Spaces, you’ll need to update the server URL in your agent configuration to point to your deployed space:
{
command: "npx",
args: [
"mcp-remote",
"https://YOUR_USERNAME-mcp-sentiment.hf.space/gradio_api/mcp/sse"
]
}This allows your agent to use the sentiment analysis tool from anywhere, not just locally!
In this unit, we’ve gone from understanding MCP basics to building a complete end-to-end application:
This demonstrates the power of the Model Context Protocol - we can create specialized tools using frameworks we’re familiar with (like Gradio), expose them through a standardized interface (MCP), and then have agents seamlessly use these tools alongside other capabilities.
The complete flow we’ve built allows an agent to:
This modular approach is what makes MCP so powerful for building flexible AI applications.