MCP resources
Overview
Control resources within a specific WordPress MCP server. Select the subject with AAM::api()->mcp_resources($access_level, $settings). Omit $access_level to use the current user or visitor.
PHP class: AAM_Framework_Service_McpResources.
Method reference
| Method | Purpose |
|---|---|
deny($resource, $server_id) |
Store a deny rule. |
allow($resource, $server_id) |
Store an allow rule. |
reset($resource = null, $server_id = null) |
Remove one rule or all rules for this level. |
is_customized($resource = null, $server_id = null) |
Check for a direct rule or preference. |
is_denied($resource, $server_id) |
Check the effective deny decision. |
is_allowed($resource, $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 resource URI string or a resource object with getUri(), followed by its server ID: deny('https://example.com/schema', 'my-server'). Use the URI, not the resource title. reset() and is_customized() allow omitted arguments to address a broader set of rules.
Example
$resources = AAM::api()->mcp_resources('role:subscriber');
$resources->deny('private-report', 'my-server');
$blocked = $resources->is_denied('private-report', 'my-server');
This denies the private-report resource on my-server for Subscribers. $blocked checks the same resource and server pair.
Developer notes
- Pass the server ID as the second argument for a named resource.
- A resource rule does not create or register the resource.
- The selected access level determines whose rules are stored or evaluated. See Access levels.
Behavior and parameters
deny($resource, $server_id)andallow()need the resource identifier and server ID.reset($resource = null, $server_id = null)clears one rule or all resource rules.is_customized()detects an explicit resource rule.is_denied()andis_allowed()resolve the effective decision.