npx claudepluginhub stackloklabs/stacklok-claude-hooksA hook that ensures MCP tool calls are only allowed for servers managed by ToolHive, regardless of whether the server is from the registry.
A hook that ensures MCP tool calls are only allowed for servers running in ToolHive and from the configured registry
A Claude Code plugin that restricts MCP (Model Context Protocol) tool calls to only servers managed by ToolHive.
MCP adoption spreads organically: MCP configurations get shared, copied from READMEs, and rarely cleaned up. Security teams lose visibility into what's connected and what data is flowing where causing security risks and compliance headaches.
ToolHive is an open-source platform that brings enterprise-grade security to MCP deployment. It provides a curated registry of approved servers, isolated container runtimes, centralized policy enforcement, and audit logging—without blocking developers from using the tools they need.
This hook is the Claude Code integration. It intercepts every MCP call before execution and verifies the target server is ToolHive-managed. Unauthorized servers are blocked with a clear error message.
When Claude Code attempts to use an MCP tool, this hook:
mcp__<server>__<tool>) to extract the server namethv list --format json) to get managed serversThis marketplace provides two plugin variants:
| Plugin | Description |
|---|---|
stacklok-hook | Allows any MCP server managed by ToolHive |
stacklok-hook-registry-restricted | Only allows servers from the ToolHive registry |
stacklok-hook: Use this if you trust all servers your team adds to ToolHive. Any server in thv list is allowed.
stacklok-hook-registry-restricted: Use this for stricter enterprise environments. Servers must be in ToolHive AND match the ToolHive registry:
brew install jq on macOS)timeout command (brew install coreutils on macOS). Linux systems typically have this pre-installed.thv CLI)Launch Claude Code in any directory:
claude
Add the marketplace:
/plugin marketplace add StacklokLabs/stacklok-claude-hooks
If you see an error about marketplace not being found or authentication failed try
/plugin marketplace add [email protected]:StacklokLabs/stacklok-claude-hooks.git
or
/plugin marketplace add https://github.com/StacklokLabs/stacklok-claude-hooks
Install your preferred plugin:
/plugin install stacklok-hook
Or for registry-restricted mode:
/plugin install stacklok-hook-registry-restricted
Select "Install for you (user scope)" when prompted.
Exit and restart Claude Code.
Clone this repository:
git clone https://github.com/StacklokLabs/stacklok-claude-hooks.git
cd stacklok-claude-hooks
Start Claude Code with the plugin directory (use absolute path):
claude --plugin-dir /path/to/stacklok-claude-hooks/plugins/stacklok-hook
Or for registry-restricted mode:
claude --plugin-dir /path/to/stacklok-claude-hooks/plugins/stacklok-hook-registry-restricted
Restart Claude Code.
/plugin uninstall stacklok-hook
Or for registry-restricted:
/plugin uninstall stacklok-hook-registry-restricted
Run the unit tests (mocks the thv CLI):
# Test default mode plugin
./plugins/stacklok-hook/tests/stacklok-hook-test.sh
# Test registry-restricted mode plugin
./plugins/stacklok-hook-registry-restricted/tests/stacklok-hook-test.sh
The hook (scripts/stacklok-hook.sh):