ag2-use-builtin-tools
Skill12 starsChanged 10 days agoApache-2.0View on GitHub
Wire AG2's shipped tools into an `Agent` instead of writing custom Python. Provider-native server-side tools in `ag2.tools` (`WebSearchTool`, `WebFetchTool` + `UrlSources` (from `ag2.tools.builtin.web_fetch`), `CodeExecutionTool`, `FileSearchTool`, `ImageGenerationTool`, `MemoryTool`, `SkillsTool`, `GoogleMapsTool`, `XSearchTool`, `MCPServerTool`); consuming MCP servers client-side (`MCPToolkit`, `MCPServerConfig`, `MCPStdioServerConfig`, `MCPAnswerPolicy`); and local toolkits for every provider (`FilesystemToolkit`, `DuckDuckSearchTool`, `TavilySearchTool`, `PerplexitySearchToolkit`, `SkillPlugin`/`SkillsToolkit`, and `ag2.extensions.tools.search` — `ExaToolkit`, `FirecrawlToolkit`, `KeenableSearchToolkit`, `SerplySearchToolkit`, `TinyFishSearchToolkit`). Use for web search/fetch, connecting an agent to an MCP server, file access, or skills. Shell (`SandboxShellTool`, `ShellTool`, `AnthropicBashTool`) → `ag2-shell-tool`; custom tools → `ag2-add-custom-tool`; serving an agent over MCP → `ag2-mcp`.
- Reads credentials
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- ag2ai/build-with-ag2their own version, first seen Oct 9, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- ag2ai/build-with-ag2★ 252same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository27 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- ag2-a2aSkill
- ag2-acpSkill
- ag2-add-custom-toolSkill
- ag2-ag-uiSkill
- ag2-eval-comparisonSkill
- ag2-evaluationSkill
- ag2-hitlSkill
- ag2-knowledge-and-memorySkill
- ag2-liveSkill
- ag2-mcpSkill
- ag2-middlewareSkill
- ag2-multimodal-inputSkill
- ag2-network-discussionSkill
- ag2-network-governanceSkill
- ag2-network-quickstartSkill
- ag2-network-tools-and-viewsSkill
- ag2-network-workflowSkill
- ag2-observers-and-alertsSkill
- ag2-overviewSkill
- ag2-quickstartSkill
- ag2-shell-toolSkill
- ag2-structured-outputSkill
- ag2-subagent-delegationSkill
- ag2-telemetrySkill
- ag2-testingSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 77
Every multi-tool toolkit exposes per-tool factories (fs.read_file(), exa.search(), serply.news(), …) so you can hand the agent a subset …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Use AG2's built-in tools
When to use
The user wants a capability AG2 already ships. Three families, all passed via Agent(tools=[...]) and freely mixed with custom tools:
- Provider-native — run server-side by Anthropic / OpenAI / Gemini / xAI / Z.AI. Support varies — check the matrix.
- MCP client —
MCPToolkit(AG2 connects; any provider; stdio or HTTP) orMCPServerTool(the provider connects). - Local toolkits — Python tools run in your process; work with every provider.
Recipes
from ag2 import Agent
from ag2.config import AnthropicConfig, OpenAIResponsesConfig
from ag2.tools import CodeExecutionTool, UserLocation, WebFetchTool, WebSearchTool
agent = Agent(
"researcher",
config=AnthropicConfig(model="claude-haiku-4-5", streaming=True), # streaming: see pitfalls
tools=[
WebSearchTool(max_uses=3, user_location=UserLocation(country="US"), allowed_domains=["pypi.org"]),
WebFetchTool(max_uses=2, citations=True), # Anthropic / Gemini only
CodeExecutionTool(), # Anthropic / OpenAI / Gemini / xAI
],
)
reply = await agent.ask("Find the ag2 PyPI page and report the latest version.")ImageGenerationTool(quality="low", size="1024x1024") (OpenAI Responses only) returns images on reply.files (BinaryResult.data).
Connect an MCP server (client side) — needs pip install "ag2[mcp]"
from ag2.tools import MCPServerConfig, MCPStdioServerConfig, MCPToolkit
tools = [
MCPToolkit("https://mcp.example.com/mcp"), # remote, no auth
MCPToolkit(MCPServerConfig(server_url="https://mcp.example.com/mcp",
authorization_token=token, tool_name_prefix="docs_")),
MCPToolkit(MCPStdioServerConfig(command="uvx", args=["mcp-server-github"],
env={"GITHUB_TOKEN": gh}, allowed_tools=["list_issues"])),
]AG2 discovers the server's tools lazily and executes them itself — works with every provider, credentials never leave your infra. MCPServerTool(server_url=..., server_label=..., allowed_tools=[...]) instead forwards URL + token to the provider (Anthropic / OpenAI Responses / xAI; URL servers only). Elicitation, protocol_mode="auto", prefixes and the full config tables: references/mcp_client.md.
Local toolkits (any provider)
import os, tempfile
from ag2.tools import DuckDuckSearchTool, FilesystemToolkit, SkillPlugin
from ag2.extensions.tools.search import KeenableSearchToolkit, SerplySearchToolkit
workspace = tempfile.mkdtemp()
agent = Agent(
"worker",
config=OpenAIResponsesConfig(model="gpt-4.1-mini"),
tools=[
FilesystemToolkit(base_path=workspace), # read/write/update/delete/find, sandboxed to base_path
DuckDuckSearchTool(max_results=5), # pip install "ag2[ddgs]", no key
KeenableSearchToolkit(max_results=5), # no extra package, works without a key
SerplySearchToolkit(api_key=os.environ["SERPLY_API_KEY"]).web(num=5), # factory = one tool only
],
plugins=[SkillPlugin("./my-skills")], # local agentskills.io skills
)Every multi-tool toolkit exposes per-tool factories (fs.read_file(), exa.search(), serply.news(), …) so you can hand the agent a subset with per-call options.
Going deeper
references/builtin_tools_matrix.md— provider × tool matrix, every parameter, Anthropic tool versions,WebFetchTool(url_sources=...),FileSearchTool,SkillsTool, all search toolkits and their install lines,SkillPluginvsSkillsToolkit.references/mcp_client.md—MCPToolkit/MCPServerToolin depth.- Upstream:
website/docs/user-guide/tools/{builtin_tools,common_toolkits,mcp_servers,toolkits}.mdx,website/docs/user-guide/skills.mdx,website/docs/user-guide/extensions/tools/search/*.mdx.
Common pitfalls
- Tool/provider mismatch raises
UnsupportedToolError(fromag2.exceptions) on the firstask— e.g.WebFetchToolon OpenAI,MemoryTooloff Anthropic,ImageGenerationTooloff OpenAI Responses. UseOpenAIResponsesConfig, notOpenAICompletionsConfig, for OpenAI built-in tools. - Anthropic + server tools truncates
reply.body(1.3.0): a cited answer arrives as many text blocks and non-streamingreply.body/content()keeps only the last one (often just"."). UseAnthropicConfig(..., streaming=True)— the streamed reply is complete. MCPServerTool(blocked_tools=...)on OpenAI / xAI raisesBlockedToolsUnsupportedError— they only take an allow-list. Useallowed_tools, orMCPToolkit, which enforcesblocked_toolseverywhere.- Version-gated
WebFetchTooloptions (use_cache≥web_fetch_20260309,response_inclusion=web_fetch_20260318) raiseWebFetchOptionUnsupportedErrorbefore the request — pass a matchingversion=. FilesystemToolkitis sandboxed — paths or glob patterns escapingbase_pathraisePermissionError;read_only=Trueexposes onlyread_file/find_files.- MCP tool-name collisions — a server tool never overrides a local tool of the same name; it is dropped with a warning. Set
tool_name_prefix. - Missing dependency — an extension whose SDK is absent imports as a placeholder that raises
ImportErrorwith the exactpip installon first use. Install before delivering code:ag2[mcp],ag2[ddgs],ag2[tavily],ag2[perplexity],"exa-py>=2.12.1,<3","firecrawl-py>=4.46,<5","tinyfish>=0.2.3". Keenable / Serply / Glasser / Xquik need no extra package. SkillsTool≠SkillPlugin—SkillsTool("xlsx")enables the provider's hosted skills;SkillPlugin/SkillsToolkitrun your own local skill directories.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

