DS DevShelfHub Projects · AI tools
Tutorials / CrewAI / Reference / Methods / create_static_tool_filter()
Method MCP

create_static_tool_filter(): Reference Guide

By DevShelfHub

Builds a filter that exposes only the named tools from an MCP server.

See the CrewAI methods catalog, CrewAI introduction, kickoff() reference, and core concepts for surrounding context.

What is create_static_tool_filter()?

Model Context Protocol servers often advertise dozens of tools — many irrelevant or too powerful for a given agent. create_static_tool_filter(['search', 'fetch_page']) wraps the adapter so CrewAI only surfaces those names to the LLM, shrinking prompts and reducing mistaken invocations. Static filters are ideal when policy is stable: finance bots always see the same subset, support bots never see destructive admin tools.

Because the allowlist keys off declared tool names, keep CI fixtures that assert the MCP manifest still contains every name you reference — upstream servers can rename tools between releases and silently drop capabilities. Pair static filters with integration tests that call each allowed tool once.

When requirements become contextual (managers see delete, interns do not), graduate to create_dynamic_tool_filter instead of growing impossible-to-maintain static matrices.

Use Cases

  • Security narrowing
  • Prompt-size control

Key Features

  • Static allowlist

When NOT to Use

Quick prototyping where you want to see everything.

Notes

Case and naming sensitivity

Tool names must match the MCP manifest exactly. Capture manifest snapshots in tests when vendors rename endpoints.

Over-pruning

Too small an allowlist causes runtime errors when the planner legitimately needs a tool you removed. Start from telemetry of actual tool usage, then trim.

Composable filters

Chaining filters is order-dependent — document whether later adapters expect already-pruned lists or the full server catalog.

Static vs dynamic

If the allowlist depends on the authenticated user or task tags, static lists become stale. Switch to create_dynamic_tool_filter for context-aware decisions.

Parameters

Parameter Type Required Purpose
names list[str] No Allowed tool names.

Code Examples

Allow

python
MCPServerAdapter(...).with_filter(create_static_tool_filter(['search', 'fetch']))

Layered allowlist constant

python
from crewai.mcp.filters import create_static_tool_filter

READ_ONLY = create_static_tool_filter(['search', 'fetch', 'list_dir'])
adapter = MCPServerAdapter(...).with_filter(READ_ONLY)

Different lists per deployment tier

python
import os
from crewai.mcp.filters import create_static_tool_filter

TOOLS = ['search'] if os.getenv('ENV') == 'prod' else ['search', 'shell', 'deploy']
flt = create_static_tool_filter(TOOLS)

When to Use

Narrowing MCP tool surfaces in production.

Common Mistakes

❌ Shipping an empty list to mean allow-all

✅ Treat empty allowlists as deny-all; omit the filter instead when you truly want every tool.

Related: @tool decorator reference, Agent class reference, and the first Crew tutorial.

create_static_tool_filter() FAQ

What is create_static_tool_filter() in CrewAI?

Builds a filter that exposes only the named tools from an MCP server. Model Context Protocol servers often advertise dozens of tools — many irrelevant or too powerful for a given agent. create_static_tool_filter(['search', 'fetch_page']) wraps the adapter so CrewAI only surfaces those names to the LLM, shrinking prompts and reducing mistaken invocations. Static filters are ideal when policy is stable: finance bots always see the same subset, support bots never see destructive admin tools. Because the allowlist keys off declared tool names, kee…

Which CrewAI types expose the method create_static_tool_filter()?

DevShelfHub documents create_static_tool_filter() on MCP. The reference maps it to Python module crewai.mcp.filters — pin your installed crewai version and match imports to the snippet on this page.

When should I use create_static_tool_filter()?

Narrowing MCP tool surfaces in production.

When should I avoid create_static_tool_filter()?

Quick prototyping where you want to see everything.

How do I call create_static_tool_filter() from Python?

flt = create_static_tool_filter(['allowed_tool'])

Where can I explore more CrewAI API reference pages?

Open the CrewAI API reference index on DevShelfHub to search classes, methods, and decorators, each with runnable examples, parameters, common mistakes, and cross-links.