mirror of
https://github.com/Heretek-AI/heretek-control-core.git
synced 2026-10-12 02:03:55 +00:00
feat(admin): move Compact tool mode to Tools tab; retire Low-tools mode
Compact tool mode (dispatcher) is the single 'stay under the client tool cap' control now, so its toggle moves from the Connection tab to the Tools tab in place of the old Low-tools card — registered under SETTINGS_GROUP so it saves with the per-tool grid, which stays interactive (call-tool still honors the toggles). Low-tools mode is fully retired: the essentials filter + get_essential_tool_slugs(), the option registration, the save-time 'paused grid' special case, the stat-count branch, the JS live-preview handler, and the CSS pause rules are all removed. The Connection tab shows a pointer to the Tools tab. Uninstaller still cleans the legacy option. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
005d50f81a
commit
d3552c5143
@@ -23,7 +23,7 @@ When editing premium-prompts behavior, the plugin code (`includes/admin/class-pr
|
||||
- With Elementor Pro: **127** (124 + 3) — **88** active by default
|
||||
- With Elementor Pro + Elementor 4.0+: **141** (138 + 3) — **102** active by default
|
||||
- With Pro + WooCommerce + Elementor 4.0+: **141** — WooCommerce widgets are reached through `add-pro-widget` (catalog tier `woo`), so they add **no** new tools.
|
||||
- Low-tools mode (any config): still available but largely obsolete — the consolidation already keeps the surface well under common client caps.
|
||||
- Low-tools mode: **removed in v3.2.0** (superseded by Compact tool mode, the Tools-tab dispatcher toggle). The catalog-backed consolidation already keeps the surface well under common client caps; clients that still cap tool counts use Compact tool mode.
|
||||
|
||||
> **v3.1.0 adds the 10 always-on Gutenberg block tools** (`list-blocks`, `get-block-schema`, `get-post-blocks`, `list-patterns`, `add-block`, `update-block`, `remove-block`, `move-block`, `duplicate-block`, `insert-pattern`) — config-independent, **+10 registered and +10 active-by-default in every configuration** (all enabled by default; only `remove-block` is badged destructive). These are the numbers already reflected in the bullets above (each is the prior v3.0.0 total + 10). v3.1.0 also brings the **AI Chat editor FAB to the Gutenberg block editor** (`EMCP_Tools_Gutenberg_Editor`, a Pro AI-Chat-module feature; adds no MCP tools).
|
||||
|
||||
@@ -109,7 +109,7 @@ emcp-tools/
|
||||
│ │ └── class-content-abilities.php # v3.0.0: 8 WordPress Content tools (list-post-types, list-taxonomies, create/get/update/list/delete-post, set-post-terms) — WP core only, never touches _elementor_data
|
||||
│ ├── class-admin-bar.php # EMCP_Tools_Admin_Bar (free, loaded unconditionally by the bootstrap — the admin bar renders on the front end too). Admin-bar MCP status node (green/grey/red dot) + one-click nonce toggle of emcp_tools_server_enabled (same option the Connection tab writes); manage_options-gated; `admin_post_emcp_tools_toggle_server` handler flips + redirects back. Pure status() unit-tested (pro/tests/unit/admin/AdminBarTest.php)
|
||||
│ ├── admin/
|
||||
│ │ ├── class-admin.php # Admin top-level menu (EMCP Tools) with 4 native submenu pages (Tools, Connection, Prompts, Changelog), stats bar, header, Low-tools mode + Pro-disabled-by-default defaults
|
||||
│ │ ├── class-admin.php # Admin top-level menu (EMCP Tools) with 4 native submenu pages (Tools, Connection, Prompts, Changelog), stats bar, header, Compact-tool-mode toggle + Pro-disabled-by-default defaults
|
||||
│ │ └── views/
|
||||
│ │ ├── page-tools.php # Tools tab: category-grouped tool toggles with bulk actions
|
||||
│ │ ├── page-connection.php # Connection tab: status cards, credential form, MCP client configs
|
||||
@@ -172,9 +172,9 @@ The MCP Adapter converts ability names like `emcp-tools/list-widgets` to tool na
|
||||
- **Schema-driven validation**: Widget settings validated against auto-generated JSON schemas before saving
|
||||
- **Catalog-backed widgets (v3.0.0)**: instead of 62 per-widget tools, a curated catalog (`includes/widgets/`) holds each widget's tier/category/curated params as DATA. The flow is discover → inspect → act: `list-widgets` (compact index, `tier`/`category`/`search` filters) → `get-widget-schema` (curated `params`, `types[]` batch, `full:true` for raw control schema) → `add-free-widget` / `add-pro-widget` (catalog defaults merged automatically) → `update-widget`. Per-turn widget tool-list cost drops ~10×; no capability is lost (any valid Elementor control passes through).
|
||||
- **Pro-aware**: Pro widget tools only register when Elementor Pro is active; core tools work with free Elementor
|
||||
- **`elementor_mcp_ability_names` filter** lives in `Elementor_MCP_Plugin::filter_disabled_tools()` (always loaded — NOT in the admin class, which only loads on `is_admin()`). It reads two options: `elementor_mcp_disabled_tools` (user toggles) and `elementor_mcp_low_tool_mode` (essentials-only). When low-tools mode is on, every name outside `Elementor_MCP_Plugin::get_essential_tool_slugs()` is excluded — this is the runtime path that keeps the count under client tool caps.
|
||||
- **`emcp_tools_ability_names` filter** lives in `EMCP_Tools_Plugin::filter_disabled_tools()` (always loaded — NOT in the admin class, which only loads on `is_admin()`). It reads the single `emcp_tools_disabled_tools` option (user toggles) and removes those names — the runtime path that honors the per-tool grid. (The old Low-tools-mode essentials filter + `get_essential_tool_slugs()` were **removed in v3.2.0**, superseded by Compact tool mode, which is now the single "stay under the client tool cap" control.)
|
||||
- **Pro widgets disabled-by-default**: on first admin page load (tracked via `elementor_mcp_defaults_applied` marker option), every Pro-badged slug from `get_all_tools()` is merged into `elementor_mcp_disabled_tools`. Users can re-enable individual Pro widgets from the Tools admin screen.
|
||||
- **Compact tool mode (dispatcher) — v3.2.0, opt-in.** Option `emcp_tools_dispatcher_mode` (Connection tab, default OFF). When ON, `register_mcp_server()` surfaces only **3 meta-tools** — `emcp-tools/list-tools` (compact catalog: name/description/category/destructive, `search`/`category` filters), `emcp-tools/get-tool-schema` (batch input schemas by name), `emcp-tools/call-tool` (run a tool by name+arguments) — instead of the ~141 individual tools, to escape client tool-count caps. `call-tool` **delegates to each target ability's own `check_permissions()`** (no privilege escalation) and refuses disabled/unknown tools; the individual abilities stay registered (reachable via `call-tool`). `EMCP_Tools_Dispatcher_Abilities` (`includes/abilities/class-dispatcher-abilities.php`) with `active_names()`/`resolve_ability()` seams; registered by the ability registrar but kept out of `ability_names`. Obsoletes Low-tools mode. The discovery context (server description + `list-tools`' `context`) also carries an environment + active-plugin inventory via `EMCP_Tools_Site_Context::environment_summary()`.
|
||||
- **Compact tool mode (dispatcher) — v3.2.0, opt-in.** Option `emcp_tools_dispatcher_mode` (**Tools tab**, default OFF — its toggle replaced the removed Low-tools-mode card, registered under `SETTINGS_GROUP` so it saves with the per-tool grid; the Connection tab shows a "moved to Tools" pointer). When ON, `register_mcp_server()` surfaces only **3 meta-tools** — `emcp-tools/list-tools` (compact catalog: name/description/category/destructive, `search`/`category` filters), `emcp-tools/get-tool-schema` (batch input schemas by name), `emcp-tools/call-tool` (run a tool by name+arguments) — instead of the ~141 individual tools, to escape client tool-count caps. `call-tool` **delegates to each target ability's own `check_permissions()`** (no privilege escalation) and refuses disabled/unknown tools; the individual abilities stay registered (reachable via `call-tool`), and the per-tool toggles still gate what `call-tool` will run (the grid stays interactive). `EMCP_Tools_Dispatcher_Abilities` (`includes/abilities/class-dispatcher-abilities.php`) with `active_names()`/`resolve_ability()` seams; registered by the ability registrar but kept out of `ability_names`. Replaces the removed Low-tools mode. The discovery context (server description + `list-tools`' `context`) also carries an environment + active-plugin inventory via `EMCP_Tools_Site_Context::environment_summary()`.
|
||||
- **Agent-facing Skills (read-side) — v3.2.0, Pro.** `EMCP_Tools_Skill_Catalog` (`pro/includes/class-skill-catalog.php`) parses the bundled `SKILL.md` skills (`pro/skills/*/SKILL.md`, dual-root via `EMCP_Tools_Pro_Loader::path('skills')`) and exposes them to connected MCP agents through **2 Pro-gated tools** — `emcp-tools/list-skills` (catalog: slug/name/description, `search` filter) and `emcp-tools/get-skill` (full body by slug, path-traversal-guarded). Read-only; both self-gate on `can_use_premium_code()` (via `EMCP_Tools_Skill_Abilities`). The free `EMCP_Tools_Site_Context::environment_summary()` gains an `emcp_tools_discovery_skills` filter seam that the catalog hooks (in `EMCP_Tools_Skill_Catalog::init()`, wired by `EMCP_Tools_Pro_Loader::wire_runtime_hooks()`) to inject a `## Skills` catalog into the discovery context — progressive disclosure: the agent sees the catalog, then pulls full bodies on demand. The skill abilities are registered by the ability registrar **outside** the Elementor gate (not Elementor-dependent). A `emcp_tools_skill_sources` filter is the extensibility seam for future sources (Premium Prompts, a user CPT). Free ships only the empty filter seam; the catalog + abilities live in `pro/` (`pro-manifest.txt` guards the leak). Reachable via `call-tool` in dispatcher mode. Tests: `pro/tests/unit/skills/` (a `Skills` suite).
|
||||
|
||||
### Modules Framework (v3.1.0)
|
||||
|
||||
@@ -2821,14 +2821,8 @@
|
||||
.elementor-mcp-tabpanel { display: none; }
|
||||
.elementor-mcp-tabpanel.is-active { display: block; }
|
||||
|
||||
/* Low-tools mode: pause/grey the per-tool grid + bulk selects (Save stays active). */
|
||||
#elementor-mcp-tools-form.is-low-mode .elementor-mcp-category,
|
||||
#elementor-mcp-tools-form.is-low-mode .elementor-mcp-enable-all,
|
||||
#elementor-mcp-tools-form.is-low-mode .elementor-mcp-disable-all {
|
||||
opacity: .55;
|
||||
pointer-events: none;
|
||||
}
|
||||
.elementor-mcp-lowmode-banner {
|
||||
/* Compact tool mode: an info banner above the still-interactive per-tool grid. */
|
||||
.elementor-mcp-compact-banner {
|
||||
margin: 0 0 14px;
|
||||
padding: 10px 14px;
|
||||
background: #eef0ff;
|
||||
@@ -2836,7 +2830,7 @@
|
||||
border-left: 3px solid #5145e5;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.elementor-mcp-lowmode-banner p { margin: 0; font-size: 13px; color: #2b2f44; }
|
||||
.elementor-mcp-compact-banner p { margin: 0; font-size: 13px; color: #2b2f44; }
|
||||
|
||||
/* Connection-tab client picker */
|
||||
.elementor-mcp-client-grid {
|
||||
|
||||
@@ -99,29 +99,6 @@
|
||||
updateCards( form );
|
||||
}
|
||||
} );
|
||||
|
||||
// Low-tools mode — live preview without a save round-trip: pause/grey the
|
||||
// grid and show the effective (essentials-only) state, then restore the
|
||||
// stored toggles when switched back off. The stored + essential state of
|
||||
// each tool is carried in data-* attributes rendered server-side.
|
||||
var lowToggle = form.querySelector( 'input[type="checkbox"][value="1"][name$="low_tool_mode"]' );
|
||||
if ( lowToggle ) {
|
||||
lowToggle.addEventListener( 'change', function () {
|
||||
var on = lowToggle.checked;
|
||||
form.classList.toggle( 'is-low-mode', on );
|
||||
form.querySelectorAll( toolCheckboxSelector ).forEach( function ( cb ) {
|
||||
if ( on ) {
|
||||
cb.checked = ( '1' === cb.dataset.essential );
|
||||
cb.disabled = true;
|
||||
} else {
|
||||
cb.checked = ( '1' === cb.dataset.storedEnabled );
|
||||
cb.disabled = false;
|
||||
}
|
||||
} );
|
||||
updateCards( form );
|
||||
updateToolCounts( form );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,15 +35,6 @@ class EMCP_Tools_Admin {
|
||||
*/
|
||||
const OPTION_DISABLED_TOOLS = 'emcp_tools_disabled_tools';
|
||||
|
||||
/**
|
||||
* Option name for the low-tools-mode toggle. When set to '1', tools
|
||||
* outside the curated essentials list are filtered out so clients
|
||||
* with tight tool caps (e.g. Antigravity) stay under their limit.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const OPTION_LOW_TOOL_MODE = 'emcp_tools_low_tool_mode';
|
||||
|
||||
/**
|
||||
* Settings group name.
|
||||
*
|
||||
@@ -618,9 +609,13 @@ class EMCP_Tools_Admin {
|
||||
)
|
||||
);
|
||||
|
||||
// Compact tool mode (dispatcher) — Tools tab. OFF by default; surfaces 3
|
||||
// meta-tools (list-tools / get-tool-schema / call-tool) instead of every
|
||||
// individual tool for clients that cap the tool count. Registered under the
|
||||
// Tools form group so its toggle lives alongside the per-tool grid.
|
||||
register_setting(
|
||||
self::SETTINGS_GROUP,
|
||||
self::OPTION_LOW_TOOL_MODE,
|
||||
EMCP_Tools_Plugin::OPTION_DISPATCHER_MODE,
|
||||
array(
|
||||
'type' => 'string',
|
||||
'default' => '0',
|
||||
@@ -658,20 +653,6 @@ class EMCP_Tools_Admin {
|
||||
)
|
||||
);
|
||||
|
||||
// Compact tool mode (dispatcher). OFF by default; surfaces 3 meta-tools
|
||||
// instead of every individual tool for clients that cap the tool count.
|
||||
register_setting(
|
||||
self::SETTINGS_GROUP_SERVER,
|
||||
EMCP_Tools_Plugin::OPTION_DISPATCHER_MODE,
|
||||
array(
|
||||
'type' => 'string',
|
||||
'default' => '0',
|
||||
'sanitize_callback' => static function ( $value ) {
|
||||
return '1' === (string) $value ? '1' : '0';
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
// OpenAI-strict tool schemas (Connection tab). OFF by default — it's only
|
||||
// for OpenAI-compatible strict function-calling clients (CrewAI, etc.) and
|
||||
// would otherwise break Gemini/Antigravity. (GitHub #42)
|
||||
@@ -801,16 +782,6 @@ class EMCP_Tools_Admin {
|
||||
&& self::SETTINGS_GROUP === sanitize_text_field( wp_unslash( $_POST['option_page'] ) );
|
||||
|
||||
if ( $is_settings_form ) {
|
||||
// When low-tools mode is saved ON, the per-tool grid is paused and
|
||||
// rendered disabled, so its checkboxes don't post. Preserve the user's
|
||||
// stored toggles rather than recomputing them to "all disabled" — the
|
||||
// toggles resume when low-tools mode is turned off again.
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing
|
||||
if ( isset( $_POST[ self::OPTION_LOW_TOOL_MODE ] ) && '1' === (string) wp_unslash( $_POST[ self::OPTION_LOW_TOOL_MODE ] ) ) {
|
||||
$existing = get_option( self::OPTION_DISABLED_TOOLS, array() );
|
||||
return is_array( $existing ) ? array_values( array_intersect( $all_tools, $existing ) ) : array();
|
||||
}
|
||||
|
||||
$enabled = array();
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing
|
||||
if ( isset( $_POST[ self::OPTION_DISABLED_TOOLS ] ) && is_array( $_POST[ self::OPTION_DISABLED_TOOLS ] ) ) {
|
||||
@@ -2630,12 +2601,6 @@ class EMCP_Tools_Admin {
|
||||
public function get_enabled_tool_count(): int {
|
||||
$all = $this->get_available_tool_slugs();
|
||||
|
||||
// Low-tools mode overrides the per-tool toggles (see filter_disabled_tools):
|
||||
// exactly the essentials are active.
|
||||
if ( '1' === (string) get_option( self::OPTION_LOW_TOOL_MODE, '0' ) ) {
|
||||
return count( array_intersect( $all, EMCP_Tools_Plugin::get_essential_tool_slugs() ) );
|
||||
}
|
||||
|
||||
$disabled = get_option( self::OPTION_DISABLED_TOOLS, array() );
|
||||
if ( ! is_array( $disabled ) ) {
|
||||
$disabled = array();
|
||||
|
||||
@@ -186,25 +186,14 @@ $emcp_tools_server_enabled = class_exists( 'EMCP_Tools_Plugin' )
|
||||
<p class="elementor-mcp-activate-note">
|
||||
<?php esc_html_e( 'Enable only for OpenAI-compatible strict function-calling clients (e.g. CrewAI) that reject the default tool schemas. It lists every property as required (optional ones become nullable) and sets additionalProperties:false. Leave this OFF for Claude, Gemini, and Antigravity — they work with the default schemas, and strict mode can break Gemini/Antigravity.', 'emcp-tools' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php // Card C: compact tool mode (dispatcher). ?>
|
||||
<div class="emcp-conn-card">
|
||||
<h2 class="emcp-conn-card-title"><?php esc_html_e( 'Compact tool mode', 'emcp-tools' ); ?></h2>
|
||||
|
||||
<label class="emcp-switch emcp-conn-toggle">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="<?php echo esc_attr( EMCP_Tools_Plugin::OPTION_DISPATCHER_MODE ); ?>"
|
||||
value="1"
|
||||
<?php checked( '1' === (string) get_option( EMCP_Tools_Plugin::OPTION_DISPATCHER_MODE, '0' ) ); ?>
|
||||
/>
|
||||
<span class="elementor-mcp-toggle" aria-hidden="true"><span class="elementor-mcp-toggle-track"></span></span>
|
||||
<span class="emcp-switch-label"><?php esc_html_e( 'Expose 3 dispatcher tools instead of every individual tool', 'emcp-tools' ); ?></span>
|
||||
</label>
|
||||
|
||||
<p class="elementor-mcp-activate-note">
|
||||
<?php esc_html_e( 'Turn this on if your MCP client caps the number of tools (e.g. some Claude Desktop builds). The server then exposes just list-tools, get-tool-schema, and call-tool: the AI discovers tools, fetches a tool\'s inputs, then runs it by name. Every tool\'s own permission still applies. Leave OFF for the full one-tool-per-ability surface.', 'emcp-tools' ); ?>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s: link to the Tools tab. */
|
||||
esc_html__( 'Looking for Compact tool mode? It now lives on the %s tab, next to the per-tool toggles it works with.', 'emcp-tools' ),
|
||||
'<a href="' . esc_url( admin_url( 'admin.php?page=emcp-tools-tools' ) ) . '">' . esc_html__( 'Tools', 'emcp-tools' ) . '</a>'
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -18,16 +18,14 @@ $emcp_tools_disabled = get_option( EMCP_Tools_Admin::OPTION_DISABLED_TOOLS,
|
||||
$emcp_tools_disabled = is_array( $emcp_tools_disabled ) ? $emcp_tools_disabled : array();
|
||||
$emcp_tools_enabled_count = $this->get_enabled_tool_count();
|
||||
$emcp_tools_total_count = $this->get_total_tool_count();
|
||||
$emcp_tools_low_mode = '1' === (string) get_option( EMCP_Tools_Admin::OPTION_LOW_TOOL_MODE, '0' );
|
||||
$emcp_tools_essentials = EMCP_Tools_Plugin::get_essential_tool_slugs();
|
||||
$emcp_tools_compact_mode = '1' === (string) get_option( EMCP_Tools_Plugin::OPTION_DISPATCHER_MODE, '0' );
|
||||
|
||||
$emcp_tools_tabs = EMCP_Tools_Admin::platform_tabs();
|
||||
$emcp_tools_buckets = EMCP_Tools_Admin::partition_by_platform( $emcp_tools_all_tools );
|
||||
$emcp_tools_elementor_active = EMCP_Tools_Bootstrap::elementor_active();
|
||||
|
||||
/**
|
||||
* Per-tab enabled/total counts, computed with the same effective-state logic
|
||||
* the category headers use (essentials in low-tools mode, else the stored set).
|
||||
* Per-tab enabled/total counts, computed from the stored disabled set.
|
||||
*/
|
||||
$emcp_tools_tab_counts = array();
|
||||
foreach ( $emcp_tools_buckets as $emcp_tools_tab_id => $emcp_tools_tab_cats ) {
|
||||
@@ -36,10 +34,7 @@ foreach ( $emcp_tools_buckets as $emcp_tools_tab_id => $emcp_tools_tab_cats ) {
|
||||
foreach ( $emcp_tools_tab_cats as $emcp_tools_cat ) {
|
||||
foreach ( $emcp_tools_cat['tools'] as $emcp_tools_s => $emcp_tools_unused ) {
|
||||
$emcp_tools_t_total++;
|
||||
$emcp_tools_eff = $emcp_tools_low_mode
|
||||
? in_array( $emcp_tools_s, $emcp_tools_essentials, true )
|
||||
: ! in_array( $emcp_tools_s, $emcp_tools_disabled, true );
|
||||
if ( $emcp_tools_eff ) {
|
||||
if ( ! in_array( $emcp_tools_s, $emcp_tools_disabled, true ) ) {
|
||||
$emcp_tools_t_enabled++;
|
||||
}
|
||||
}
|
||||
@@ -59,27 +54,27 @@ $emcp_tools_badge_labels = array(
|
||||
);
|
||||
?>
|
||||
|
||||
<form method="post" action="options.php" id="elementor-mcp-tools-form" class="<?php echo esc_attr( $emcp_tools_low_mode ? 'is-low-mode' : '' ); ?>">
|
||||
<form method="post" action="options.php" id="elementor-mcp-tools-form">
|
||||
<?php settings_fields( EMCP_Tools_Admin::SETTINGS_GROUP ); ?>
|
||||
|
||||
<div class="elementor-mcp-low-mode-card">
|
||||
<label class="elementor-mcp-low-mode-toggle">
|
||||
<input type="hidden" name="<?php echo esc_attr( EMCP_Tools_Admin::OPTION_LOW_TOOL_MODE ); ?>" value="0" />
|
||||
<input type="hidden" name="<?php echo esc_attr( EMCP_Tools_Plugin::OPTION_DISPATCHER_MODE ); ?>" value="0" />
|
||||
<input
|
||||
type="checkbox"
|
||||
name="<?php echo esc_attr( EMCP_Tools_Admin::OPTION_LOW_TOOL_MODE ); ?>"
|
||||
name="<?php echo esc_attr( EMCP_Tools_Plugin::OPTION_DISPATCHER_MODE ); ?>"
|
||||
value="1"
|
||||
<?php checked( $emcp_tools_low_mode ); ?>
|
||||
<?php checked( $emcp_tools_compact_mode ); ?>
|
||||
/>
|
||||
<span class="elementor-mcp-toggle" aria-hidden="true">
|
||||
<span class="elementor-mcp-toggle-track"></span>
|
||||
</span>
|
||||
<span class="elementor-mcp-low-mode-info">
|
||||
<span class="elementor-mcp-low-mode-title">
|
||||
<?php esc_html_e( 'Low-tools mode (Antigravity-friendly)', 'emcp-tools' ); ?>
|
||||
<?php esc_html_e( 'Compact tool mode', 'emcp-tools' ); ?>
|
||||
</span>
|
||||
<span class="elementor-mcp-low-mode-desc">
|
||||
<?php esc_html_e( 'Keeps the active tool count under 60 by exposing only a curated set of essential abilities. Use this when your MCP client enforces a strict tool cap. Your individual toggles below are preserved and take effect again when this is turned off.', 'emcp-tools' ); ?>
|
||||
<?php esc_html_e( 'Exposes 3 dispatcher tools (list-tools, get-tool-schema, call-tool) instead of every individual tool, so MCP clients that cap the tool count can still reach the whole surface. Your per-tool toggles below stay in effect — call-tool refuses any tool you disable. Reconnect your client after changing this.', 'emcp-tools' ); ?>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
@@ -111,16 +106,10 @@ $emcp_tools_badge_labels = array(
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $emcp_tools_low_mode ) : ?>
|
||||
<div class="elementor-mcp-lowmode-banner">
|
||||
<?php if ( $emcp_tools_compact_mode ) : ?>
|
||||
<div class="elementor-mcp-compact-banner">
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %d: number of essential tools active in low-tools mode */
|
||||
esc_html__( 'Low-tools mode is active — only the %d essential tools (highlighted below) are exposed to your AI client. Your individual toggles are paused and resume when you turn low-tools mode off above.', 'emcp-tools' ),
|
||||
(int) $emcp_tools_enabled_count
|
||||
);
|
||||
?>
|
||||
<?php esc_html_e( 'Compact tool mode is active — your client sees only the 3 dispatcher tools (list-tools, get-tool-schema, call-tool). The per-tool toggles below still control what call-tool is allowed to run.', 'emcp-tools' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@@ -194,10 +183,7 @@ $emcp_tools_badge_labels = array(
|
||||
$emcp_tools_cat_total = count( $emcp_tools_category['tools'] );
|
||||
$emcp_tools_cat_enabled = 0;
|
||||
foreach ( $emcp_tools_category['tools'] as $emcp_tools_slug => $emcp_tools_tool ) {
|
||||
$emcp_tools_eff = $emcp_tools_low_mode
|
||||
? in_array( $emcp_tools_slug, $emcp_tools_essentials, true )
|
||||
: ! in_array( $emcp_tools_slug, $emcp_tools_disabled, true );
|
||||
if ( $emcp_tools_eff ) {
|
||||
if ( ! in_array( $emcp_tools_slug, $emcp_tools_disabled, true ) ) {
|
||||
$emcp_tools_cat_enabled++;
|
||||
}
|
||||
}
|
||||
@@ -235,19 +221,16 @@ $emcp_tools_badge_labels = array(
|
||||
<div class="elementor-mcp-tools-grid" id="<?php echo esc_attr( $emcp_tools_grid_id ); ?>">
|
||||
<?php foreach ( $emcp_tools_category['tools'] as $emcp_tools_slug => $emcp_tools_tool ) : ?>
|
||||
<?php
|
||||
$emcp_tools_is_enabled = $emcp_tools_low_mode
|
||||
? in_array( $emcp_tools_slug, $emcp_tools_essentials, true )
|
||||
: ! in_array( $emcp_tools_slug, $emcp_tools_disabled, true );
|
||||
$emcp_tools_is_enabled = ! in_array( $emcp_tools_slug, $emcp_tools_disabled, true );
|
||||
?>
|
||||
<label class="elementor-mcp-tool-card <?php echo esc_attr( ( $emcp_tools_is_enabled ? 'is-enabled' : 'is-disabled' ) . ( $emcp_tools_cat_unavailable ? ' is-unavailable' : '' ) ); ?>">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="<?php echo esc_attr( EMCP_Tools_Admin::OPTION_DISABLED_TOOLS ); ?>[]"
|
||||
value="<?php echo esc_attr( $emcp_tools_slug ); ?>"
|
||||
data-essential="<?php echo esc_attr( in_array( $emcp_tools_slug, $emcp_tools_essentials, true ) ? '1' : '0' ); ?>"
|
||||
data-stored-enabled="<?php echo esc_attr( in_array( $emcp_tools_slug, $emcp_tools_disabled, true ) ? '0' : '1' ); ?>"
|
||||
<?php checked( $emcp_tools_is_enabled ); ?>
|
||||
<?php disabled( $emcp_tools_low_mode || $emcp_tools_cat_unavailable ); ?>
|
||||
<?php disabled( $emcp_tools_cat_unavailable ); ?>
|
||||
/>
|
||||
<span class="elementor-mcp-toggle" aria-hidden="true">
|
||||
<span class="elementor-mcp-toggle-track"></span>
|
||||
|
||||
@@ -57,7 +57,6 @@ class EMCP_Tools_Migration {
|
||||
public static function migrate(): void {
|
||||
$option_map = array(
|
||||
'elementor_mcp_disabled_tools' => 'emcp_tools_disabled_tools',
|
||||
'elementor_mcp_low_tool_mode' => 'emcp_tools_low_tool_mode',
|
||||
'elementor_mcp_defaults_applied' => 'emcp_tools_defaults_applied',
|
||||
'elementor_mcp_server_enabled' => 'emcp_tools_server_enabled',
|
||||
);
|
||||
|
||||
+2
-120
@@ -137,15 +137,6 @@ class EMCP_Tools_Plugin {
|
||||
* @return string[] Ability names with disabled tools removed.
|
||||
*/
|
||||
public function filter_disabled_tools( array $names ): array {
|
||||
// Low-tools mode is an OVERRIDE preset, not an addition: expose exactly
|
||||
// the curated essentials (intersected with what's actually registered),
|
||||
// regardless of the per-tool toggles. The toggles stay stored and resume
|
||||
// the moment low-tools mode is turned off — which is why turning it on
|
||||
// always yields the essentials even if every tool was previously disabled.
|
||||
if ( '1' === (string) get_option( 'emcp_tools_low_tool_mode', '0' ) ) {
|
||||
return array_values( array_intersect( $names, self::get_essential_tool_slugs() ) );
|
||||
}
|
||||
|
||||
$disabled = get_option( 'emcp_tools_disabled_tools', array() );
|
||||
if ( ! is_array( $disabled ) || empty( $disabled ) ) {
|
||||
return $names;
|
||||
@@ -154,115 +145,6 @@ class EMCP_Tools_Plugin {
|
||||
return array_values( array_diff( $names, $disabled ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Curated list of essential tool slugs kept active in low-tools mode.
|
||||
*
|
||||
* Trimmed to fit under a 60-tool budget while preserving every category
|
||||
* an AI agent needs to build a page from scratch: discovery, page CRUD,
|
||||
* layout, the catalog-backed widget tools (add-free-widget / add-pro-widget /
|
||||
* update-widget), globals, templates, stock images, custom code, and (when
|
||||
* Elementor 4.0+ is active) the atomic universal + container tools.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function get_essential_tool_slugs(): array {
|
||||
return array(
|
||||
// Query / discovery (7).
|
||||
'emcp-tools/list-widgets',
|
||||
'emcp-tools/get-widget-schema',
|
||||
'emcp-tools/get-page-structure',
|
||||
'emcp-tools/get-element-settings',
|
||||
'emcp-tools/list-pages',
|
||||
'emcp-tools/list-templates',
|
||||
'emcp-tools/get-global-settings',
|
||||
|
||||
// Page CRUD (5).
|
||||
'emcp-tools/create-page',
|
||||
'emcp-tools/update-page-settings',
|
||||
'emcp-tools/delete-page-content',
|
||||
'emcp-tools/import-template',
|
||||
'emcp-tools/export-page',
|
||||
|
||||
// Layout / structure (10).
|
||||
'emcp-tools/add-container',
|
||||
'emcp-tools/move-element',
|
||||
'emcp-tools/remove-element',
|
||||
'emcp-tools/duplicate-element',
|
||||
'emcp-tools/update-container',
|
||||
'emcp-tools/get-container-schema',
|
||||
'emcp-tools/find-element',
|
||||
'emcp-tools/update-element',
|
||||
'emcp-tools/batch-update',
|
||||
'emcp-tools/reorder-elements',
|
||||
|
||||
// Widget tools — catalog-backed (3 insert/update; discovery already
|
||||
// listed in the Query block above).
|
||||
'emcp-tools/add-free-widget',
|
||||
'emcp-tools/add-pro-widget',
|
||||
'emcp-tools/update-widget',
|
||||
|
||||
// Templates (2).
|
||||
'emcp-tools/save-as-template',
|
||||
'emcp-tools/apply-template',
|
||||
|
||||
// Globals (2).
|
||||
'emcp-tools/update-global-colors',
|
||||
'emcp-tools/update-global-typography',
|
||||
|
||||
// Composite (1).
|
||||
'emcp-tools/build-page',
|
||||
|
||||
// Stock images (3).
|
||||
'emcp-tools/search-images',
|
||||
'emcp-tools/sideload-image',
|
||||
'emcp-tools/add-stock-image',
|
||||
|
||||
// SVG icons (1).
|
||||
'emcp-tools/upload-svg-icon',
|
||||
|
||||
// Custom code (4).
|
||||
'emcp-tools/add-custom-css',
|
||||
'emcp-tools/add-custom-js',
|
||||
'emcp-tools/add-code-snippet',
|
||||
'emcp-tools/list-code-snippets',
|
||||
|
||||
// Atomic essentials (5) — only registered when Elementor 4.0+.
|
||||
'emcp-tools/detect-elementor-version',
|
||||
'emcp-tools/add-atomic-widget',
|
||||
'emcp-tools/update-atomic-widget',
|
||||
'emcp-tools/add-flexbox',
|
||||
'emcp-tools/add-div-block',
|
||||
|
||||
// WordPress content (8) — general post/page/CPT management.
|
||||
'emcp-tools/list-post-types',
|
||||
'emcp-tools/list-taxonomies',
|
||||
'emcp-tools/create-post',
|
||||
'emcp-tools/get-post',
|
||||
'emcp-tools/update-post',
|
||||
'emcp-tools/list-posts',
|
||||
'emcp-tools/delete-post',
|
||||
'emcp-tools/set-post-terms',
|
||||
|
||||
// WordPress settings (2) — curated site-settings read/update.
|
||||
'emcp-tools/get-settings',
|
||||
'emcp-tools/update-settings',
|
||||
|
||||
// WordPress plugins & themes (2 reads — writes opt-in only).
|
||||
'emcp-tools/list-plugins',
|
||||
'emcp-tools/list-themes',
|
||||
|
||||
// WordPress media (2 — detail read + metadata edit; delete is opt-in).
|
||||
'emcp-tools/get-media',
|
||||
'emcp-tools/update-media',
|
||||
|
||||
// WordPress users (2 reads — writes opt-in only).
|
||||
'emcp-tools/list-users',
|
||||
'emcp-tools/get-user',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Option name for the "Activate Abilities API for EMCP" server gate.
|
||||
*
|
||||
@@ -333,8 +215,8 @@ class EMCP_Tools_Plugin {
|
||||
|
||||
/**
|
||||
* Returns the active (post-filter) ability names — the exact set exposed to
|
||||
* the MCP server, with user-disabled tools, Low-tools mode, and
|
||||
* Pro-disabled-by-default already removed. Used by the AI Chat
|
||||
* the MCP server, with user-disabled tools and Pro-disabled-by-default
|
||||
* already removed. Used by the AI Chat
|
||||
* /execute-ability and /abilities endpoints so the chat can never run a tool
|
||||
* the admin disabled. Triggers the lazy Abilities API init if it hasn't run.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user