MCPcopy
hub / github.com/codeaashu/claude-code / hashMcpConfig

Function hashMcpConfig

src/services/mcp/utils.ts:157–169  ·  view source on GitHub ↗
(config: ScopedMcpServerConfig)

Source from the content-addressed store, hash-verified

155 * `{b:2,a:1}` hash the same.
156 */
157export function hashMcpConfig(config: ScopedMcpServerConfig): string {
158 const { scope: _scope, ...rest } = config
159 const stable = jsonStringify(rest, (_k, v: unknown) => {
160 if (v && typeof v === 'object' && !Array.isArray(v)) {
161 const obj = v as Record<string, unknown>
162 const sorted: Record<string, unknown> = {}
163 for (const k of Object.keys(obj).sort()) sorted[k] = obj[k]
164 return sorted
165 }
166 return v
167 })
168 return createHash('sha256').update(stable).digest('hex').slice(0, 16)
169}
170
171/**
172 * Remove stale MCP clients and their tools/commands/resources. A client is

Callers 1

Calls 3

jsonStringifyFunction · 0.85
keysMethod · 0.80
updateMethod · 0.65

Tested by

no test coverage detected