Controlling which tools a model can call with LiteLLM

How to use LiteLLM's tool permission guardrail to allow or deny tool calls by name and type, and constrain arguments, across OpenAI, Anthropic and MCP tools.

On this page

How do you control which tools a model can call through LiteLLM?

When models sit behind a shared gateway, any caller that can reach a model may also be able to trigger the tools that model requests, and those tools can read files, query databases or change systems that the caller should never touch. LiteLLM's tool permission guardrail addresses this at the gateway: it filters tool calls by name and type with allow and deny regex rules, so the gateway can block a tool the model asked for before the call is passed on. The guardrail covers OpenAI tool_calls, Anthropic tool_use and MCP tools, and it can validate nested tool arguments as well as the tool name.

Teams usually need this control once models do more than answer questions. Agents that run multi-step tasks, MCP servers that expose internal systems, and developer tools that ship with broad default permissions all turn a model's tool request into a real action. Before you write rules, inventory which tools each team, key or model is expected to use, and decide which are denied by default. Confirm in your own environment how your chosen client sends tool definitions and tool results, because rules written against names that a client never sends will match nothing.

The guardrail does not replace permissions in the systems the tools call. A deny rule at the gateway stops the request from being forwarded, but the database, file share or API behind the tool still needs its own least-privilege credentials and audit trail. Regex rules also depend on tool naming discipline, so ask whether your teams can rename or add tools without changing gateway policy, and plan a review step for new MCP servers. Test every rule with a retest after each change, because a rule that passes one client's tool format may miss another's.

Rule and configuration options and when each fits

This table compares allow lists, deny lists, name-based and type-based regex rules, and argument validation, showing what each one controls and where it fits. Read each row as a choice you make per team, key or service account, then combine rows where one control alone leaves a gap. The main takeaway is that deny rules block known risky tools, while allow rules and argument checks suit environments where only specific calls should ever run.

OptionWhat it controlsWhen it fitsWhat to confirm
Allow list (regex)Only tool calls whose name or type matches an approved pattern may runService accounts that should use a short set of read-only MCP toolsExact pattern syntax and how multiple allow rules combine in your version
Deny list (regex)Tool calls whose name or type matches a blocked pattern are refusedBlocking shell or file-write tools for a particular team while leaving other tools openWhether deny rules take precedence over allow rules in your release
Name-based ruleMatches the specific tool name the model requestsWhen you know the exact function or MCP tool names you want to governNaming differences between OpenAI tool_calls, Anthropic tool_use and MCP tool names
Type-based ruleMatches the category of tool call rather than one nameWhen new tools of a known kind should be governed without editing rules each timeWhich type values your deployment exposes for each provider format
Argument validationNested tool arguments must match approved formats before the call proceedsLimiting file paths, query fields or command parameters even when the tool name is allowedHow deeply nested arguments are checked and how failures are reported to callers

Where the tool permission check sits in a request

The request starts in the calling application, which sends a chat request to the LiteLLM gateway with a virtual key. The gateway checks the key, then forwards the request to the model provider. When the model's response contains a tool call, such as an OpenAI tool_calls entry, an Anthropic tool_use block or an MCP tool, the response passes back through the gateway before the caller sees it. The tool permission rules compare the tool name, type and arguments against allow and deny lists. The trust boundaries sit between the client, the gateway and the provider, so confirm that every tool call is evaluated at the gateway before it reaches the caller.

Tool calls are checked at the gateway before any caller receives them.

Setting up tool permission rules in LiteLLM

This sequence takes a team from confirming that the tool permission guardrail is available in their LiteLLM release to proving that allow and deny rules block or pass the tool calls each provider format produces. The output is a tested rule set attached to the keys or models it governs.

  1. Confirm release and guardrail availability

    Check which LiteLLM release your gateway runs and confirm in the tool permission guardrail documentation that the feature, its configuration keys and the tool types you need are present in that release. Compare your release against the current entries on the LiteLLM releases page, and record the version you will test against. Confirm with the vendor or your own staging deployment, not from memory, whether the feature is open source or limited to Enterprise for your edition. The step is done when you have a written version number and a yes or no on guardrail availability.

  2. Define the tool inventory for each team

    List every tool each team's applications or agents expose to a model, including function names from OpenAI tool_calls, tool_use names from Anthropic requests and MCP tool names from registered servers. Group them by team and by risk, separating read-only lookups from tools that write data, send messages or call external systems. Ask each team owner to sign off on the list, because the rules you write next depend on names that already exist. The step is done when every team has a named inventory that someone accountable has approved.

  3. Write allow and deny regex rules

    Translate the inventory into allow and deny regular expressions on tool name and tool type, starting with a deny rule for anything that is not approved and narrow allow rules for approved names. Anchor patterns so that a rule for a read tool does not also match a write tool with a similar prefix. Where tools take arguments, write validation for nested fields that accepts only approved formats, such as a fixed account identifier pattern or a limited set of values. Store the rule file in version control. The step is done when the file passes a review in which a second person checks each pattern against the inventory.

  4. Attach the guardrail to keys or models

    Add the guardrail to the configuration and bind it to the virtual keys or model groups that belong to each team, so that unrelated traffic is not affected by a rule meant for another team. Check the binding in the admin UI or the configuration file by confirming that a key from one team shows the expected guardrail and a key from another team does not. Record which keys and models carry each rule set. The step is done when the attachment is visible for every key in scope and absent from keys that should not have it.

  5. Test allowed tool calls for each provider format

    Send sample requests that make the model produce a tool call in each format you run: an OpenAI tool_calls response, an Anthropic tool_use block and an MCP tool invocation. Use a tool name from the approved inventory and a valid argument, and confirm that the request completes and the call is passed through unchanged. Run the same test through each team's key so you see the policy for each binding. The step is done when every format returns the approved call without modification.

  6. Test denied and malformed tool calls

    Send sample requests that trigger each deny rule, an unapproved tool name, a tool of a blocked type, and an argument that breaks the approved format, using the same three provider formats. Confirm that the gateway blocks or rejects each call, that the rejection message does not expose internal rule details beyond what your team needs, and that the attempt appears in the request logs. Illustrative example: a write-type tool requested through a read-only key should be denied and logged under that key. The step is done when every deny case is blocked and logged in each format.

  7. Record the test results and schedule a review

    Save the test requests, the expected results and the actual results alongside the rule file and the release version, so that a later upgrade or rule change can be retested against the same cases. Ask the owner of each team to confirm that the inventory still matches what their applications send. Confirm the review cadence with your security and platform leads, since the tool list will change as teams add capabilities. The step is done when the test set is stored with the configuration and every team owner has signed the inventory.

How the rules differ for OpenAI, Anthropic and MCP tools

Requests and responses in the OpenAI format carry tool activity in a tool_calls array on assistant messages. Each entry names a function and passes its arguments as a JSON string, which is where nested argument checks have to look. Because LiteLLM uses the OpenAI request format for more than 100 providers, a team that calls OpenAI-style endpoints will often see this shape even when the model behind the gateway is hosted elsewhere. Confirm the exact field paths the guardrail reads against the tool permission documentation before writing rules.

  • Name field: Deny and allow regex rules match the function name inside each tool_calls entry, so test an exact name and a near-miss name.
  • Type field: Confirm how the guardrail identifies the tool type for function calls, and test that a non-function type is handled as you expect.
  • Stringified arguments: Arguments arrive as a JSON string, so test that nested argument validation parses them and rejects malformed input.
  • Parallel calls: A single response can contain several tool calls, so test that one disallowed call blocks the whole response or is handled as your policy states.
  • Streaming: Test whether tool call fragments arriving in chunks are evaluated before they reach the caller.

Check each point against the LiteLLM tool permission documentation for your version.

Security risks a tool permission guardrail reduces, and gaps it leaves

A tool permission guardrail narrows what a model can ask to run, which cuts off several routes to data loss and over-privileged actions. It does not cover everything, and its rules are only as good as their naming and matching. Read each card as one risk and one check you should confirm in your own environment.

Data exfiltration through tools

A model that can call a send, upload or post tool can move data out of your environment without any user asking for it, especially when a prompt or tool output contains hostile instructions. Use allow rules on tool names so that only tools with a documented business purpose are callable, and deny outbound-capable tools for teams that handle regulated data. Check that the rules cover every tool exposed through the gateway, not just the ones your team tested.

Tool permission docs

Over-broad agent permissions

Agents often arrive with every tool from a server enabled, so a coding or workplace agent may hold far more capability than its task needs. A tool permission guardrail lets you limit each key or team to the tool names it needs, which turns a broad default into a short, reviewable list. Ask the agent owner which actions are needed for each workflow and confirm that the list matches that answer before rollout.

Regex rules that are too loose or too narrow

A pattern such as a wildcard on tool names can allow a tool added later by accident, while an anchored pattern can miss a renamed or namespaced tool and block legitimate work. Test each pattern against the full list of tool names your servers return, and keep a dated record of who approved each rule. Treat rule changes like code changes with review and a rollback plan.

Bypass through tools not matched by name or type

A rule written for one tool name or type may not match the same action exposed under a different name, through a different MCP server, or inside a nested call. Confirm how the guardrail classifies OpenAI tool_calls, Anthropic tool_use and MCP tools in your LiteLLM version, and test each path separately. Argument validation for nested fields should also be checked, since a permitted tool can still receive a harmful value.

Gaps that need other controls

The guardrail decides whether a tool call is permitted, but it does not authenticate the MCP server, limit the credentials that server uses, or record what happened after a call ran. Pair it with MCP server authentication, least-privilege credentials for each upstream system, and request logging so you can see which calls were attempted and blocked. Confirm that each of these exists for every tool your models can reach.

Operating and testing tool rules after rollout

Tool rules need the same discipline as code once they are live, because a rule that blocks the right call today can quietly stop matching after a tool is added, renamed or given new arguments. Before each change to the rule set, run a regression pass that replays representative prompts and expected tool calls from every OpenAI tool_calls, Anthropic tool_use and MCP tool your teams rely on, and confirm that the allowed calls still pass and the denied ones still stop. Add a test case for each new tool at the same time it is registered, and include a nested-argument case for any tool whose arguments you validate. Confirm with the vendor how the tool permission guardrail reports matches so your test assertions check the right outcome.

Blocked calls are the best early signal that a rule is too broad or that a team is trying to reach a tool it should not. Review the LiteLLM logs for denied tool calls on a fixed schedule, grouping them by key, team, model and tool name, and look for patterns such as one team repeatedly hitting the same deny rule. Decide in advance who reviews these logs, what counts as a false positive, and how a rule is corrected. Confirm which log fields your deployment records for guardrail actions, since the detail you need for review depends on your logging configuration.

Rule sets should have a named owner, a written change request and an approval step before anything reaches production, because a single regex edit can open a tool to every key on the gateway. Keep rule definitions in version-controlled configuration and promote them through the same path as other gateway settings. Rule changes also interact with per-team guardrail policies: a rule attached globally applies everywhere, while a team-level policy may add or override checks. Before you change a global rule, map which teams and keys inherit it, and retest their tool access after the change. Confirm with the vendor which of these policy features your edition supports.

Limits to confirm in your environment

The tool permission guardrail depends on the LiteLLM release, edition, streaming behavior, payload handling and transports you run. Confirm each of these against the vendor documentation and a test environment before you write policy that depends on it.

Release and edition

Confirm which LiteLLM release and license edition include the tool permission guardrail in your deployment, and whether it is available in the open source code or only in the Enterprise directory. The open source and Enterprise code sit under different licenses, so check the path of the feature against the LICENSE file. Pin the release you tested and record it in your change log, because guardrail behavior can change between releases.

Latest listed release
v1.105.1
Tool permission docs

Streaming response coverage

Confirm whether allow and deny rules apply to tool calls that arrive in streamed responses, where a tool call is assembled from partial chunks. A rule that only inspects complete responses can miss a call that the client has already started to execute. Test a streamed OpenAI tool_calls response and a streamed Anthropic tool_use block with a deny rule, and confirm what the caller receives.

Nested and large argument payloads

Confirm how argument validation handles deeply nested objects, long string values and large arrays. Ask whether validation stops at a depth limit, whether oversized payloads are rejected or passed through, and what error the caller sees. Write test cases with nested paths that sit just inside and just outside your approved formats, including payloads near the size your agents typically send.

Supported MCP transports

Confirm which MCP transports the guardrail inspects, such as stdio, HTTP-based streaming or server-sent events, and whether tool names are matched the same way on each. An MCP tool that arrives over a transport the guardrail does not see is outside the policy. Test each transport your MCP servers use, and check how tool names with namespace prefixes are matched by your regex rules.

Database needs for stored rules

Confirm whether rules managed through the admin interface or stored in the database require PostgreSQL in your setup, and how rule changes reach each proxy instance. LiteLLM's production guide names PostgreSQL as the primary supported database and calls for Redis once more than one instance runs. Check that a rule change applied on one instance is enforced on all of them within a time window your security team accepts.

Production guide

Questions buyers ask about tool permission rules in LiteLLM

Can our own team configure tool permission rules in LiteLLM without a partner?

Yes, a team with gateway and regex experience can write allow and deny rules on tool names and types. The LiteLLM tool permission guardrail supports allow and deny regex rules across OpenAI tool_calls, Anthropic tool_use and MCP tools, and it can validate nested tool arguments. The harder part is not the syntax but deciding which tools each team should reach, keeping those decisions current as tools change, and proving that the rules block what they should. Your team needs an owner for the rule set, a review step for new tools, and a test suite that runs after every change. Check the exact configuration keys against the LiteLLM tool permission docs for the version you run.

What drives the effort of a tool permission rule project?

Effort grows with three things: the number of tools the models can call, the number of model providers, and the number of teams that need different permissions. Each provider expresses tool calls in its own format, so rules must be checked against OpenAI tool_calls, Anthropic tool_use and any MCP servers you connect. Each team that needs a different allow list adds rules to write, review and test. Nested tool arguments add more work because each argument you constrain needs its own validation case. A small, single-provider set of tools is a narrow task. A broad estate with many MCP servers and several teams is a larger one.

What do we need to provide before the work starts?

Prepare three inputs before any rule is written. First, a tool inventory: every tool name, its type (function, Anthropic tool_use or MCP tool), the server or application that exposes it, and whether it writes data, sends messages or touches money. Second, named owners: one person per tool or tool group who can approve it for a team. Third, test cases: examples of requests that should succeed, requests that should be denied, and tool arguments that must be rejected. Without these, rules tend to be either too broad or so narrow that teams route around the gateway. Agree the inventory and owners in writing so the scope is clear before anyone quotes or starts.

How long does testing take for tool permission rules?

Testing time depends on scope: how many tools, providers, teams and argument constraints must be covered. A limited pilot with one provider and a handful of tools is a short exercise. Testing a full estate covers each provider format, each team's allow list, deny rules that overlap, and argument validation for nested fields, and it should be repeated after each change to rules or to the LiteLLM version. No duration figure is supplied for this work, so ask any partner or your own team to state the test matrix and the retest plan in the written scope, and to tie the timeline to that matrix.

What costs are one-time and what costs recur?

The one-time costs are the inventory, the initial rule design, the first test suite and the rollout to each team. The recurring costs are reviewing new tools, updating rules when a provider or MCP server changes its tool names, rerunning tests after LiteLLM upgrades, and handling exceptions that teams request. Ask for a quote that separates these items, names who performs each one, and states what is included in a retest. The cost of the open-source software itself is not part of this work. Staff time and any partner fees are.

Does a tool permission guardrail stop every unsafe tool call?

No single guardrail should be treated as complete protection. Tool permission rules control which tool names and types a model may invoke and can constrain arguments, but they depend on accurate tool names and on the rules covering every path a call can take. Rules can miss tools that are renamed, added by a new MCP server, or invoked through a route that is not covered. Treat the guardrail as one control among several, pair it with least-privilege credentials on the tools themselves, and test it with deliberately hostile requests. Confirm the coverage of each provider path during testing.

Is an outside partner worth bringing in for this work?

A partner adds value when the rule set spans several providers, many teams and multiple MCP servers, or when your team lacks time to build a repeatable test suite. DeployOpen implements and hardens self-hosted open-source platforms in your own infrastructure, and it runs security testing that includes AI systems and agents, which covers testing tool permissions against prompt injection and misuse. Work is usually fixed-scope, with scope, deliverables and timelines agreed in writing before work starts. Ongoing testing and upgrades can be handled under a retainer. Ask any firm to show its test cases for your tools, not only its rule syntax.

What should we check when a LiteLLM upgrade changes tool handling?

Rerun the full tool permission test suite on the new version in a non-production environment before promoting it. Check that allow and deny rules still match tool names for each provider format, that argument validation still rejects the test inputs, and that denied calls are logged the way your audit process expects. LiteLLM supports the four most recent stable minor versions, so plan upgrades on that cadence and confirm current release details on the LiteLLM releases page. Keep the rule set in version control so each change has a reviewer and a record.

How DeployOpen scopes and delivers tool permission controls

DeployOpen approaches tool permission controls in LiteLLM as a written, fixed-scope piece of work inside your own infrastructure. We first map which tools each team, key and model may reach, then build and test the allow and deny rules before anything reaches production.

How we scope

  • Inventory every tool type in use across OpenAI tool_calls, Anthropic tool_use and MCP tools.
  • Agree which tool names and types each team, key and model may invoke, in writing.
  • Define how nested tool arguments must be validated against approved formats.

How we build

  • Write allow and deny regex rules for tool names and types in your LiteLLM configuration.
  • Configure argument validation for nested fields so unapproved formats are rejected.
  • Test blocked and permitted calls against each provider format and MCP server in scope.

How we hand over

  • Document the rule set, its owners, and the process for changing rules and reviewing denials.
  • Store configuration in your version control so changes are reviewed and traceable.
  • Walk your security and platform teams through the test results and the remaining open risks.

How we support

  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
  • Ongoing support, upgrades and continuous testing are available as a retainer.
  • Retesting after LiteLLM upgrades or new MCP servers is included when it is part of the agreed scope.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.