MCPcopy Create free account
hub / github.com/modelcontextprotocol/inspector / isReservedMetaKey

Function isReservedMetaKey

client/src/utils/metaUtils.ts:96–120  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

94 * @see https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta
95 */
96export 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.

Callers 4

filterReservedMetadataFunction · 0.90
updateMetadataFunction · 0.90
MetadataTabFunction · 0.90
ToolsTabFunction · 0.90

Calls 2

getPrefixSegmentFunction · 0.85
splitLabelsFunction · 0.85

Tested by

no test coverage detected