feat: hide tool list and instructions from users without LIT MCP access

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
2026-09-26 03:13:05 +02:00
co-authored by Claude Opus 5.5
parent 2f8a9f0c61
commit 2674bf2ed1
4 changed files with 150 additions and 0 deletions
+18
View File
@@ -120,6 +120,24 @@ wp user create lit-smoke-sub lit-smoke-sub@example.invalid --role=subscriber >/d
SUB_TOKEN=$(mint_token lit-smoke-sub)
SUB_INIT=$(mcp "$SUB_TOKEN" '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"smoke","version":"0"}}}')
SUB_SESSION=$(echo "$SUB_INIT" | grep -i '^mcp-session-id:' | awk '{print $2}' | tr -d '\r' || true)
# 5a. Visibility (Task 7): VisibilityFilter hides our server's tool list and
# instructions from a subscriber entirely, before AbilityRegistrar's own
# per-call deny below is even reached. tools/list comes back empty (no direct
# tools, no meta-tools either – the adapter still accepts an empty array, see
# HandlerHelperTrait::validate_filtered_list); instructions carry only the
# no-access notice, never integration names or post types.
echo "$SUB_INIT" | grep -q 'nicht freigegeben' \
|| fail "subscriber initialize instructions lack the no-access notice: $SUB_INIT"
echo "$SUB_INIT" | grep -Eq 'Inhaltstypen|Divi|Pods|Aktive Integrationen|Direkt aufrufbare Tools' \
&& fail "subscriber initialize instructions leak integration/post-type details: $SUB_INIT"
pass "subscriber initialize instructions carry only the no-access notice"
SUB_LIST=$(mcp "$SUB_TOKEN" '{"jsonrpc":"2.0","id":10,"method":"tools/list"}' "$SUB_SESSION")
echo "$SUB_LIST" | grep -q '"tools":\[\]' \
|| fail "subscriber tools/list is not empty: $SUB_LIST"
pass "subscriber tools/list is empty (no direct tools, no meta-tools)"
SUB_CALL=$(mcp "$SUB_TOKEN" '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"lit-site-status","arguments":{}}}' "$SUB_SESSION")
echo "$SUB_CALL" | grep -Eq '"isError":[[:space:]]*true|"error":[[:space:]]*\{' || fail "subscriber could call lit-site-status: $SUB_CALL"
# The denial text must actually be our role-gate message, not just any error