-
Notifications
You must be signed in to change notification settings - Fork 786
[Tiny Agents] Add tools to config #3242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Wauplin
merged 7 commits into
huggingface:main
from
NielsRogge:feature/add_tools_exclusion
Sep 1, 2025
+22
−2
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
33eac44
Add tools to config
NielsRogge 147a2a1
Merge remote-tracking branch 'upstream/main' into feature/add_tools_e…
NielsRogge 19b5b9e
Simplify MCP tool filtering to use allowed_tools parameter
NielsRogge 69d21dd
Merge remote-tracking branch 'upstream/main' into feature/add_tools_e…
NielsRogge 809774d
Address comments
NielsRogge 582eecf
Merge remote-tracking branch 'upstream/main' into feature/add_tools_e…
NielsRogge c52aae1
Update src/huggingface_hub/inference/_mcp/mcp_client.py
Wauplin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,4 +139,7 @@ dmypy.json | |
# Spell checker config | ||
cspell.json | ||
|
||
tmp* | ||
tmp* | ||
|
||
# Claude Code | ||
CLAUDE.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Tool Filtering Demo | ||
|
||
This example demonstrates the new tool filtering feature for tiny agents. | ||
|
||
## Configuration | ||
|
||
The `agent.json` shows how to filter tools from MCP servers: | ||
|
||
```json | ||
{ | ||
"servers": [ | ||
{ | ||
"type": "stdio", | ||
"command": "npx", | ||
"args": ["@playwright/mcp@latest"], | ||
"tools": { | ||
"include": ["browser_click", "browser_close"] | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## Tool Filtering Options | ||
|
||
### Include only specific tools | ||
```json | ||
"tools": { | ||
"include": ["tool1", "tool2", "tool3"] | ||
} | ||
``` | ||
|
||
### Exclude specific tools | ||
```json | ||
"tools": { | ||
"exclude": ["unwanted_tool1", "unwanted_tool2"] | ||
} | ||
``` | ||
|
||
### Combine both (exclude takes precedence) | ||
```json | ||
"tools": { | ||
"include": ["tool1", "tool2", "tool3"], | ||
"exclude": ["tool2"] | ||
} | ||
``` | ||
Result: Only `tool1` and `tool3` will be available. | ||
|
||
## Running the Example | ||
|
||
```bash | ||
tiny-agents run examples/tool_filtering_demo | ||
``` | ||
|
||
This agent will have access to only the `browser_click` and `browser_close` tools from Playwright, instead of all 30+ tools that Playwright provides by default. |
NielsRogge marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"model": "meta-llama/Meta-Llama-3-8B-Instruct", | ||
"provider": "auto", | ||
"servers": [ | ||
{ | ||
"type": "stdio", | ||
"command": "npx", | ||
"args": ["@playwright/mcp@latest"], | ||
"tools": { | ||
"include": ["browser_click", "browser_close"] | ||
} | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NielsRogge marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Tiny agents (https://huggingface.co/blog/python-tiny-agents) is a minimalistic framework for running AI agents. When running a tiny agent with `huggingface_hub` using the `tiny-agents run agent` command, the command will look for an `agent.json` file which defines the configuration of the agent. Each agent is defined by an LLM (powered by Hugging Face Inference Providers which is similar to the OpenAI API) as well as a set of MCP servers, whose tools will be provided to the LLM. Currently, one can just add certain MCP servers to the config, such as the one below: | ||
|
||
```json | ||
{ | ||
"model": "Qwen/Qwen2.5-72B-Instruct", | ||
"provider": "nebius", | ||
"inputs": [ | ||
{ | ||
"type": "promptString", | ||
"id": "github-personal-access-token", | ||
"description": "Github Personal Access Token (read-only)", | ||
"password": true | ||
} | ||
], | ||
"servers": [ | ||
{ | ||
"type": "stdio", | ||
"command": "docker", | ||
"args": [ | ||
"run", | ||
"-i", | ||
"--rm", | ||
"-e", | ||
"GITHUB_PERSONAL_ACCESS_TOKEN", | ||
"-e", | ||
"GITHUB_TOOLSETS=repos,issues,pull_requests", | ||
"ghcr.io/github/github-mcp-server" | ||
], | ||
"env": { | ||
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github-personal-access-token}" | ||
} | ||
}, | ||
{ | ||
"type": "stdio", | ||
"command": "npx", | ||
"args": [ | ||
"@playwright/mcp@latest" | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
However it would be nice to have a feature that allows users to define which tools to enable/disable in the config JSON file. For example, for the Playwright MCP server (which by default has more than 30 tools), I actually only need the `browser_click` and `browser_close` tools. Enabling only a handful of tools makes AI agents much more reliable. | ||
|
||
Would you be able to implement this feature? |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.