# Thư viện Agent

## tiny-agents

Bộ công cụ nhẹ để chạy các tác nhân sử dụng MCP trên nền tảng Hugging Face Inference. Có sẵn trong [JavaScript](https://huggingface.co/docs/huggingface.js/en/tiny-agents/README) (`@huggingface/tiny-agents`) và [Python](https://huggingface.co/docs/huggingface_hub/main/en/package_reference/mcp) (`huggingface_hub`).

```bash
# JavaScript
npx @huggingface/tiny-agents run "agent/id"

# Python
pip install "huggingface_hub[mcp]"
tiny-agents run "agent/id"
```

Tạo tác nhân của riêng bạn với cấu hình `agent.json`:

```json
{
	"model": "Qwen/Qwen2.5-72B-Instruct",
	"provider": "together",
	"servers": [
		{
			"type": "stdio",
			"command": "npx",
			"args": ["@playwright/mcp@latest"]
		}
	]
}
```

Đối với LLM cục bộ, hãy thêm `endpointUrl` trỏ đến máy chủ của bạn (ví dụ: `http://localhost:1234/v1`). Tìm hiểu thêm trong [hướng dẫn SDK](./agents-sdk).

## Gradio MCP Server

Biến bất kỳ ứng dụng Gradio nào thành một máy chủ MCP chỉ với một dòng thay đổi:

```python
demo.launch(mcp_server=True)
```

Máy chủ phơi bày mỗi hàm dưới dạng một công cụ, với mô tả được tự động tạo từ docstring. Kết nối nó với bất kỳ client MCP nào. Hàng nghìn Spaces tương thích MCP có sẵn trên [Hub](https://huggingface.co/spaces?filter=mcp-server). Tìm hiểu thêm trong [hướng dẫn Gradio MCP](https://www.gradio.app/guides/building-mcp-server-with-gradio).

## smolagents

[smolagents](https://github.com/huggingface/smolagents) là một thư viện Python nhẹ để xây dựng các agent chỉ với vài dòng code. Nó hỗ trợ `CodeAgent` (viết các hành động bằng Python) và `ToolCallingAgent` (sử dụng các tool call dạng JSON), hoạt động với bất kỳ model nào thông qua [Inference Providers](../inference-providers/index), và tích hợp với các MCP server.

```bash
smolagent "Plan a trip to Tokyo, Kyoto and Osaka between Mar 28 and Apr 7." \
--model-type "InferenceClientModel" \
--model-id "Qwen/Qwen2.5-Coder-32B-Instruct" \
--tools "web_search"
```

Các Agent có thể được đẩy lên Hub dưới dạng Spaces. Duyệt các agent của cộng đồng [tại đây](https://huggingface.co/spaces?filter=smolagents&sort=likes). Tìm hiểu thêm trong [tài liệu smolagents](https://huggingface.co/docs/smolagents/tutorials/tools#use-mcp-tools-with-mcpclient-directly).

