fix: MCP pineap.set_filter supports delete/clear/allow_all

The tool only accepted set_mode/add, so entries added via MCP could never be
removed. Now passes the full action set through to the same endpoint the UI
uses and returns the resulting mode/entries. Verified on device: add ->
delete round trip leaves the filter empty.
This commit is contained in:
2026-08-19 00:07:08 -05:00
parent f6b4cadc39
commit 1be93bc24b
@@ -3781,15 +3781,19 @@ def _mcp_tools():
return {'error': 'kind must be ssid or client'}
action = (args.get('action') or '').strip()
payload = {'action': action}
if action == 'set_mode':
if action in ('set_mode', 'add'):
payload['mode'] = (args.get('mode') or 'deny').strip()
elif action == 'add':
if action == 'add':
payload['value'] = (args.get('value') or '').strip()
if not payload['value']:
return {'error': 'value required'}
elif action == 'delete':
payload['mode'] = (args.get('mode') or 'deny').strip()
payload['value'] = (args.get('value') or '').strip()
if not payload['value']:
return {'error': 'value required'}
else:
return {'error': 'action must be set_mode or add'}
elif action not in ('clear', 'allow_all'):
return {'error': 'action must be set_mode, add, delete, clear or allow_all'}
status, resp = h_filter_post(_Ctx_args(payload), kind)
return resp if status == 200 else {'error': resp.get('error', 'filter failed')}
@@ -3833,9 +3837,9 @@ def _mcp_tools():
_mcp_tool('recon.isearch', 'Find APs matching an SSID in the recon database.', {'ssid': {'type': 'string'}}, recon_isearch),
_mcp_tool('recon.devices', 'Recent observed client devices from recon.', {'limit': {'type': 'number'}}, recon_devices),
_mcp_tool('pineap.kick_client', 'Disconnect a client from a PineAP/evil-twin AP.', {'mac': {'type': 'string'}}, kick),
_mcp_tool('pineap.set_filter', 'Set the SSID/client filter: action=set_mode (mode=deny|allow) or add (value).',
_mcp_tool('pineap.set_filter', 'Set the SSID/client filter: action=set_mode (mode=deny|allow), add (mode, value), delete (mode, value), clear, or allow_all. Returns the current mode and entries.',
{'kind': {'type': 'string', 'enum': ['ssid', 'client']},
'action': {'type': 'string', 'enum': ['set_mode', 'add']},
'action': {'type': 'string', 'enum': ['set_mode', 'add', 'delete', 'clear', 'allow_all']},
'mode': {'type': 'string', 'enum': ['allow', 'deny']},
'value': {'type': 'string'}}, set_filter),
]