(data: unknown)
| 168 | } |
| 169 | |
| 170 | function computeHash(data: unknown): number { |
| 171 | const str = jsonStringify(data) |
| 172 | if (typeof Bun !== 'undefined') { |
| 173 | const hash = Bun.hash(str) |
| 174 | // Bun.hash can return bigint for large inputs; convert to number safely |
| 175 | return typeof hash === 'bigint' ? Number(hash & 0xffffffffn) : hash |
| 176 | } |
| 177 | // Fallback for non-Bun runtimes (e.g. Node.js via npm global install) |
| 178 | return djb2Hash(str) |
| 179 | } |
| 180 | |
| 181 | /** MCP tool names are user-controlled (server config) and may leak filepaths. |
| 182 | * Collapse them to 'mcp'; built-in names are a fixed vocabulary. */ |
no test coverage detected