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
| 1 | import type { Settings } from 'claude-code' |
| 2 | |
| 3 | import { isServerFileUnreadable } from './is-server-file-unreadable' |
| 4 | import { orgPluginNames } from './org-plugin-names' |
| 5 | import { orgServerNames } from './org-server-names' |
| 6 | import { spellingsOf } from './spellings-of' |
| 7 | import { toolPrefixOf } from './tool-prefix-of' |
| 8 | import { foldedName } from './tool-prefix-of/folded-name' |
| 9 | |
| 10 | /** |
| 11 | * Whether a tool is the organization's: `mcp__<name>__...` for a server its |
| 12 | * policy names or delivers, and a tool under a seated plugin's name or |
| 13 | * scope (`plugin_<name>`, which holds its own manifest's servers). |
| 14 | * |
| 15 | * A server is told by its name whole, as the engine spells it (spellingsOf), |
| 16 | * never by a fold: another server whose name only begins like it is not it. |
| 17 | * A seated plugin is told fold to fold, as the registration check tells it |
| 18 | * (foldedName), since policy may list its id in another letter case. Where |
| 19 | * the server file cannot be read, every `mcp__` tool counts. |
| 20 | * |
| 21 | * @param policy the managed settings, as `$.settings.read` answers them |
| 22 | * @param tool the tool's name, as the model sees it |
| 23 | * @returns true when the tool is the organization's |
| 24 | */ |
| 25 | export const isOrgTool = (policy: Settings, tool: string): boolean => |
| 26 | (isServerFileUnreadable(policy) && tool.startsWith('mcp__')) || |
| 27 | orgServerNames(policy) |
| 28 | .flatMap(spellingsOf) |
| 29 | .some(spelt => tool.startsWith(`mcp__${spelt}__`)) || |
| 30 | orgPluginNames(policy) |
| 31 | .filter(name => foldedName(name) !== '') |
| 32 | .flatMap(name => [name, `plugin_${name}`]) |
| 33 | .some(owner => `${foldedName(tool)}_`.startsWith(toolPrefixOf(owner))) |