MCP tools
Overview
Control tools within a specific WordPress MCP server. Select the subject with AAM::api()->mcp_tools($access_level, $settings). Omit $access_level to use the current user or visitor.
PHP class: AAM_Framework_Service_McpTools.
Method reference
| Method | Purpose |
|---|---|
deny($tool, $server_id) |
Store a deny rule. |
allow($tool, $server_id) |
Store an allow rule. |
reset($tool = null, $server_id = null) |
Remove one rule or all rules for this level. |
is_customized($tool = null, $server_id = null) |
Check for a direct rule or preference. |
is_denied($tool, $server_id) |
Check the effective deny decision. |
is_allowed($tool, $server_id) |
Check the effective allow decision. |
Return values vary by method. Rule updates usually return bool; reads can return a value, null, or an array. Errors follow the service’s error_handling setting and may produce WP_Error.
Accepted identifiers
Pass the tool name string or a tool object with getName(), followed by its server ID: deny('search_posts', 'my-server'). The server ID is required because tool names are scoped to a server. reset() and is_customized() allow omitted arguments to address a broader set of rules.
Example
$tools = AAM::api()->mcp_tools('role:subscriber');
$tools->deny('delete-record', 'my-server');
$blocked = $tools->is_denied('delete-record', 'my-server');
This denies the delete-record tool on my-server for Subscribers. $blocked checks that tool within that server.
Developer notes
- Pass the server ID as the second argument for a named tool.
- Use
reset()without arguments only when you intend to clear all tool rules for this access level. - The selected access level determines whose rules are stored or evaluated. See Access levels.
Behavior and parameters
deny($tool, $server_id)andallow()need the tool name and server ID.reset($tool = null, $server_id = null)clears one rule or all tool rules.is_customized()detects an explicit tool rule.is_denied()andis_allowed()resolve the effective decision.