(key: string)
| 94 | * @see https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta |
| 95 | */ |
| 96 | export const isReservedMetaKey = (key: string): boolean => { |
| 97 | const trimmedKey = key.trim(); |
| 98 | if (!trimmedKey) { |
| 99 | return false; |
| 100 | } |
| 101 | |
| 102 | const candidateSegment = getPrefixSegment(trimmedKey) ?? trimmedKey; |
| 103 | const labels = splitLabels(candidateSegment); |
| 104 | if (!labels || labels.length < 2) { |
| 105 | return false; |
| 106 | } |
| 107 | |
| 108 | for (let i = 0; i < labels.length - 1; i += 1) { |
| 109 | const current = labels[i]; |
| 110 | const next = labels[i + 1]; |
| 111 | if ( |
| 112 | RESERVED_NAMESPACE_LABELS.includes(current) && |
| 113 | META_PREFIX_LABEL_REGEX.test(next) |
| 114 | ) { |
| 115 | return true; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | return false; |
| 120 | }; |
| 121 | |
| 122 | /** |
| 123 | * Validates the optional prefix portion of a metadata key. |
no test coverage detected