MCPcopy Index your code
hub / github.com/modelcontextprotocol/registry / IsValidTemplatedURL

Function IsValidTemplatedURL

internal/validators/utils.go:166–193  ·  view source on GitHub ↗

IsValidTemplatedURL validates a URL with template variables against available variables For packages: validates that template variables reference package arguments or environment variables For remotes: validates that template variables reference the transport's variables map

(rawURL string, availableVariables []string)

Source from the content-addressed store, hash-verified

164// For packages: validates that template variables reference package arguments or environment variables
165// For remotes: validates that template variables reference the transport's variables map
166func IsValidTemplatedURL(rawURL string, availableVariables []string) bool {
167 // First check basic URL structure
168 if !IsValidURL(rawURL) {
169 return false
170 }
171
172 // Extract template variables from URL
173 templateVars := extractTemplateVariables(rawURL)
174
175 // If no templates are found, it's a valid static URL
176 if len(templateVars) == 0 {
177 return true
178 }
179
180 // Validate that all template variables are available
181 availableSet := make(map[string]bool)
182 for _, v := range availableVariables {
183 availableSet[v] = true
184 }
185
186 for _, templateVar := range templateVars {
187 if !availableSet[templateVar] {
188 return false
189 }
190 }
191
192 return true
193}

Callers 2

validatePackageTransportFunction · 0.85
validateRemoteTransportFunction · 0.85

Calls 2

IsValidURLFunction · 0.85
extractTemplateVariablesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…