Skip to main content
Version: v5.2

MCP Tool Filter

Overview​

MCP clients can struggle when a large number of tools are available. To address this issue, you can apply filters so that only the necessary tools are exposed.

A MCP Tool filter is a saved, reusable, rule set for selecting tools. The filter can be referred to while configuring the MCP server in the MCP client.

Ways to apply MCP Tool filter​

You can apply a MCP Tool filter in two ways:

How to create a MCP Tool filter​

To create a MCP Tool filter, refer to the sample code below.

const filters = [
{
_namespaces: ['building_1234'],
_name: 'search-by-name',
_description: 'Filters tools that support name based lookup',
_userType: 'search_tool_filter',
_criteria: {
_name: { $regex: '.*search.*' }
}
}
];
await IafAISvc.createMcpToolFilters(filters, ctx);

Refer to the sections below for notes on this code sample.

_criteria property​

The supported values for the _criteria property are:

  • _name
  • _serviceName (from tool_config._serviceName)
  • _type (system_mcp_tool or user_mcp_tool)

Operators​

You can also use the following operators with _criteria:

  • For exact match: _type: system_mcp_tool
  • For checking in-list: "_serviceName:" { "$in": ["IafFileSvc", "IafItemSvc"] }
  • For Regex: "_name": { "$regex": "^get.*_IafFileSvc$" }

Apply MCP Tool filter in the MCP Server URL​

You can use the MCP Tool filter by passing the filter parameter in the MCP Server URL

Refer to the sample API call below.

https://dev1-api.in.invicara.com/aisvc/api/v1/stateless/mcp/tools?nsfilter=<YOUR_NS>&filter=demo_file_item_system_tools

The filter parameter can have the following values:

  • filter=<filter UUID>
  • filter=<filter _userType>

How to apply inline query parameters​

If you do not want to create a saved filter resource, you can filter directly in the MCP URL.

Note the supported query parameters:

  • _serviceName (repeatable) → { "_serviceName": { "$in": [...] } }
  • _name (repeatable) → { "_name": { "$in": [...] } }
  • _type (repeatable) → { "_type": { "$in": [...] } }

Examples​

Refer to the examples below for a range of different scenarios.

Example 1: Only tools from one service​

.../stateless/mcp/tools?nsfilter=<YOUR_NS>&_serviceName=IafAISvc

Example 2: Allow multiple services​

.../stateless/mcp/tools?nsfilter=<YOUR_NS>&_serviceName=IafFileSvc&_serviceName=IafItemSvc

Example 3: Allow only specific tool names​

.../stateless/mcp/tools?nsfilter=<YOUR_NS>&_name=getFiles_IafFileSvc&_name=getNamedUserItems_IafItemSvc

Example 4: Combined​

.../stateless/mcp/tools?nsfilter=<YOUR_NS>&_type=system_mcp_tool&_serviceName=IafFileSvc&_serviceName=IafItemSvc

Notes on using inline parameters​

When using inline parameters, note the following behavior:

  • If filter=... is present then the inline query parameters are ignored (filter takes precedence).
  • Inline criteria supports only strings and { "$in": [...] } notation. No $regex is allowed via query parameters).