spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / sec-default / hooks / tool-register-refusal / register-refusal-of.ts
GitHub Actions (publish-mods)chore: Update mods/ 3deb873 · 13 days ago History
31 lines · 1.1 KBRaw
1import type { Settings } from 'claude-code'
2
3import Policy from '../policy'
4import { serverNameRefusal } from './server-name-refusal.js'
5import { TOOL_REGISTER_REFUSAL } from './tool-register-refusal.js'
6
7/**
8 * Why managed policy refuses a tool to a plugin a person installed, if it
9 * does.
10 *
11 * Either an MCP allowlist is in force, or the tool would be called by a name
12 * that reads as a tool of a server of the organization's.
13 *
14 * @param policy the managed settings, as `$.settings.read` answers them
15 * @param plugin the registering plugin's name
16 * @param tool the tool's own name, as the plugin registers it
17 * @param id the id the engine recorded for the registering plugin, where
18 * the mod heard its admission
19 * @returns the refusal, or undefined when the plugin may add its tool
20 */
21export const registerRefusalOf = (
22 policy: Settings,
23 plugin: string,
24 tool: string,
25 id?: string,
26) =>
27 Policy.hasMcpAllowlist(policy)
28 ? TOOL_REGISTER_REFUSAL
29 : Policy.namesOrgTool(policy, plugin, tool, id)
30 ? serverNameRefusal(plugin)
31 : undefined