View a markdown version of this page

Add tools and skills - Amazon Bedrock

Add tools and skills

An agent's tools do things, and its skills tell it how. The built-in tools run in your tool runner. MCP tools come from an Amazon Bedrock AgentCore Gateway, which the service calls as the session role. Custom tools run in your own application. Skills are files in your tool runner.

The examples here use the cma shell function from Run your first agent. Agent changes go in POST /agents or POST /agents/{id}. Configuration changes create new versions; an update that changes nothing, or only sets the role, does not.

Topics

Built-in tools

{"type": "agent_toolset_20260401"} in an agent's tools turns on the built-in tools. With no other settings, all of them are on. Name a permission policy too. If you don't set a permission policy, the toolset uses auto. This agent's tools run without asking:

{ "tools": [{ "type": "agent_toolset_20260401", "default_config": { "permission_policy": { "type": "always_allow" } } }] }

Tool

What it does

bash

Runs a shell command.

read, write, edit

Read, write, and change files.

glob, grep

Find files by name, and find lines in files.

They run in the session's tool runner, with the tool runner's files, network, and credentials. See Protect the tool runner.

A bash command stops after 2 minutes unless the model sets timeout_ms, and never runs longer than 8 hours. To let commands run longer than 2 minutes, say so in the system prompt, for example "Set timeout_ms to 3600000 for builds." The session stays running while the command runs.

On AgentCore Runtime, a container lasts at most 8 hours from when it started, so a long command started late in a container's life is stopped when the container is replaced. The call can then run again from the start in a new container, which does not have the old container's files unless the session uses session storage (see the session-storage example). Make long commands safe to run twice, or have them save their progress where a rerun can find it.

web_fetch and web_search are not available in this preview, and a configs entry that names either one is refused. For web search, add the Web Search Tool to an AgentCore Gateway and name the gateway in the agent's mcp_servers, as in the web-search example. An agent can also use bash with a tool such as curl, if the tool runner's image has it and its network allows it.

Permission policies

Turn built-in tools off, or choose how each call is approved.

Policy

What happens on a call

always_allow

The call runs without asking.

always_ask

The turn stops before the call runs, and waits for your user.tool_confirmation.

auto

The service checks each call with a Claude model and then runs it, refuses it, or waits for your confirmation. Calls to read, glob, and grep aren't checked. If the check can't be made, the call waits for your confirmation. This is the default when you don't set a permission policy.

default_config applies to every built-in tool, and configs sets one tool. This agent can't write files, and must ask before it runs bash. Its other tools run without asking:

{ "tools": [{ "type": "agent_toolset_20260401", "default_config": { "permission_policy": { "type": "always_allow" } }, "configs": [ { "name": "write", "enabled": false }, { "name": "edit", "enabled": false }, { "name": "bash", "permission_policy": { "type": "always_ask" } } ] }] }

A tool with always_ask stops the turn before it runs. You allow or deny the call with a user.tool_confirmation event, as Allow or deny a tool call describes. Skills, and folders named in a session's resources, need the read tool. A session on an agent with skills and the read tool turned off fails to create.

MCP tools from an AgentCore Gateway

An agent can use the tools of an Amazon Bedrock AgentCore Gateway. The gateway is the only kind of MCP server an agent can name. To use another MCP server, put it behind a gateway as a target.

{ "name": "ticket-agent", "execution_identity": {"type": "aws_role", "role_arn": "arn:aws:iam::111122223333:role/ClaudeManagedAgentsSessionRole"}, "model": "us.anthropic.claude-sonnet-5-5", "mcp_servers": [{ "type": "aws_agentcore_gateway", "name": "tickets", "gateway_arn": "arn:aws:bedrock-agentcore:us-west-2:111122223333:gateway/tickets-abc1234567" }], "tools": [ { "type": "agent_toolset_20260401", "default_config": { "permission_policy": { "type": "always_allow" } } }, { "type": "mcp_toolset", "mcp_server_name": "tickets", "default_config": { "permission_policy": { "type": "always_ask" } }, "configs": [{ "name": "tickets___search_tickets", "permission_policy": { "type": "always_allow" } }] } ] }

Each entry in mcp_servers needs one mcp_toolset entry in tools with the same name, and an agent can have up to 20 servers. configs sets a tool by the name the gateway gives it, <target>___<tool>: in this example, the search_tickets tool on a gateway target named tickets.

The service calls the gateway, not your tool runner, and it signs the calls as the session role. Give the session role bedrock-agentcore:InvokeGateway on the gateway's ARN. The CloudFormation template's GatewayArn parameter adds that permission. The gateway's own authorization then decides what the call may do.

The model writes the arguments to every MCP call. Have the tools behind the gateway check their arguments, and check that the caller may act on the resource, before they do anything.

The support-desk example puts a Lambda function behind a gateway, with always_ask on one tool. The web-search example uses the managed Web Search Tool behind a gateway. The gateway names each tool <target>___<tool>, and configs uses that name.

Custom tools

A custom tool runs in your application, not in the tool runner. Define its name, description, and a JSON Schema for its input:

{ "tools": [{ "type": "custom", "name": "get_weather", "description": "Get the current weather for a city.", "input_schema": { "type": "object", "properties": { "city": { "type": "string" } }, "required": ["city"] } }] }

When the agent calls it, the session emits agent.custom_tool_use and goes idle with requires_action. Run the tool and send the result in a user.custom_tool_result event. See Return a custom tool's result. The invoice-reconciliation example makes 31 custom tool calls in one turn, several in parallel, with error results.

Skills

A skill is a folder with a SKILL.md file whose front matter gives the skill's name and description, and a body that tells the agent what to do. An agent's skills list names folders in the tool runner that hold skills. A path can contain several skill folders:

{ "skills": [{ "type": "sandbox_path", "path": "/opt/skills" }] }

With /opt/skills/release-notes/SKILL.md in the tool runner's image:

--- name: release-notes description: Write release notes from the git log between two tags. --- When asked for release notes, run `git log --oneline <from>..<to>` in the repository, group the commits by area, and write one line for each user-visible change.

When a session starts, the service reads the front matter of every SKILL.md under each path and tells the model which skills exist and where. It does that whenever the agent has the bash tool, whatever its permission policy. Otherwise the model is told to look in each path itself. A session lists at most 100 skills, and an agent can name up to 20 paths.

Skills are ordinary files, so put them where the tool runner can read them: in the image for AgentCore, or on the machine for self-hosted. A skill's commands and the programs it uses must exist there too. The path cannot be /mnt/memory or under it, and a session's working_directory cannot be at or under a skills path. A skills folder can also be an S3 folder ("type": "s3_mount"), which the tool runner mounts read-only on an AgentCore Runtime. See Use S3 folders and files.

Tell the agent about folders

A session's resources can name folders or files the tool runner already holds, with a description and instructions the agent reads before the system prompt:

{ "resources": [ { "type": "sandbox_path", "path": "/opt/reference-data", "description": "Rate tables, refreshed with each image build", "instructions": "Read these. Never change them." }, { "type": "sandbox_path", "path": "/mnt/workspace/out", "is_output": true } ] }

is_output: true tells the agent to put finished work there, and lets your application find it later from the session. The service mounts nothing for these entries and does not check that the path exists. To have the tool runner mount an S3 folder or copy an S3 file instead, name an s3_mount or s3_object entry, as Use S3 folders and files shows. A session can name up to 20 sandbox_path, s3_mount, and s3_object entries in all.

The model is told to treat what it finds in these files as information, not as instructions. That is a request to the model. It does not stop a file from steering the agent.

More than one agent

An agent, the coordinator, can call other agents as subagents. Give it a multiagent list:

{ "multiagent": { "type": "coordinator", "agents": [{ "type": "agent", "id": "agent_..." }, { "type": "self" }] } }

Each subagent runs in its own thread in the same session, with its own tools and skills, and the same tool runner. Because the tool runner is shared, every thread can read the skills folders of the coordinator and of every agent it lists, at the versions the list pins when the session is created. A coordinator can list up to 20 agents. An agent it lists cannot have a multiagent list of its own. The session's events include session.thread_created and the agent.thread_* events, and GET /sessions/{id}/threads lists the threads.

Threads share one tool runner, and their calls run one at a time. A long command in one thread delays the others, and threads that write the same path overwrite each other. Give a subagent only the tools it needs, and if it must write, give each call its own folder. The contract-review example shows the pattern.

Memory across sessions

A session keeps its own conversation. To carry what an agent learns into later sessions, give it a memory store. A memory store holds text files, called memories, that the service keeps. An agent reads and changes them with the memory tools, and your application reads and changes the same memories through the API.

Create a store, and optionally write a memory into it:

POST /memory_stores { "name": "payments-oncall", "description": "What the payments on-call engineers hand over" } POST /memory_stores/{store_id}/memories { "path": "/escalation.md", "content": "# Payments escalation\n\nPage the payments manager.\n" }

Give the agent the memory toolset:

{ "tools": [{ "type": "memory_toolset_20261030" }] }

Then attach the store to a session in its resources:

{ "resources": [{ "type": "memory_store", "memory_store_id": "memstore_...", "access": "read_write" }] }

access is read_write, the default, or read_only. A session can use only the stores it attaches. When all attached stores are read-only, the agent is offered only reading tools. With both access modes attached, writing tools are available for the read-write stores, and the service refuses a writing tool call that names a read-only store.

Tool

What it does

memory_list, memory_read, memory_search

List, read, and search the memories in attached stores.

memory_write, memory_str_replace, memory_append, memory_delete

Write a whole memory, replace text in one, add to one, and delete one.

The service runs the memory tools itself, so they need no tool runner. memory_write and memory_delete are refused for a memory whose current text the agent's thread has not read, so an agent cannot overwrite or delete a change it has not seen.

Every change to a memory adds a memory version. A version made by a memory tool names the session, the thread, and the tool call in created_by. A version made through the API names the IAM role that made the call. GET /memory_stores/{id}/memory_versions lists them, and POST /memory_stores/{id}/memory_versions/{version_id}/redact empties an old version's text and keeps its record. The current version cannot be redacted.

To update a memory only if nobody changed it since you read it, send its content_sha256 as a precondition. A memory that changed answers 409:

POST /memory_stores/{store_id}/memories/{memory_id} { "content": "...", "precondition": { "type": "content_sha256", "content_sha256": "..." } }

The memory example runs both sides against one store and checks that they agree.

On AgentCore, a session's container can be replaced after the runtime's idle timeout, and files in the container go with it. AgentCore session storage keeps a session's files across containers; the session-storage example shows what it keeps. For files that must outlast the session, use S3 folders (see Use S3 folders and files), or mount Amazon S3 Files on the runtime, as in the s3-files example.