Limit the tools an agent can use from an integration
Add toolFilters to a provider entry when you create a session, for example { type: "tool_keys", keys: ["webSearch"] }, so the session serves only those tools.
To give an agent only some of a provider's tools, add toolFilters to that provider's entry when you create the session. { type: 'tool_keys', keys: ['webSearch'] } serves one tool, and { type: 'tool_regex', pattern: '^(list|get|search)' } serves every tool whose key matches. Metorial applies the filter on its side, so the agent can neither see nor call the rest.
What you'll learn
- How to find a provider's tool keys
- How to filter tools for one session or for every session of a deployment
- How to confirm what the agent sees
Before you start
- Install the CLI and sign in
- A secret API key in
METORIAL_API_KEY - A provider deployment ID in
METORIAL_PROVIDER_DEPLOYMENT_ID. The examples use Metorial Search, created withmetorial-admin providers deployments create --provider-id metorial-search --name "Metorial Search".
Find the tool keys
A filter names tools by key. List a provider's versions, then the tools of the latest one:
Metorial Search has two tools, webSearch and getWebContent.
Filter one session
Install the SDK and an adapter:
This program connects with a filter and prints the tools the agent would get. Save it as filter.ts or filter.py.
Filter types for tools:
tool_keys: an exact list,{ type: 'tool_keys', keys: ['webSearch'] }.tool_regex: a pattern, matched without regard to case,{ type: 'tool_regex', pattern: '^(list|get|search)' }.tool_categories: the provider's own tool categories,{ type: 'tool_categories', keys: ['<category-key>'] }.
A tool passes when any rule in the list matches it. Each provider entry has its own filter, so one session can give full access to one app and read access to another.
Filter every session of a deployment
Set the filter on the deployment and it applies to every session that uses it. A session filter can narrow it further.
In the dashboard, the same setting is Tool Filters on an integration, where you allow or reject read-only, write and destructive tools as groups. See Create an integration.
Check it worked
The program prints the one tool you allowed, with the provider prefix, next to metorial_connection_status, the diagnostic tool Metorial adds to every session. The AI SDK adapter lowercases tool names, so the TypeScript program prints them in lower case.
Without toolFilters, the same program also prints metorial_search_getWebContent.
Troubleshooting
Tool access not allowed
The agent called a tool the filter excludes, for example one it remembered from an earlier session. Add the tool's key to the filter if the agent should have it.
The session has no tools from the provider
No tool matched. Compare the keys in your filter with the output of metorial-admin providers tools list.
Next steps
- Sessions: how providers, filters and connections fit together
- Use tools from several apps in one session: a different filter for each provider
- Give teams read-only access: tool filters for people who connect through a portal