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

Function extractTemplateVariables

internal/validators/utils.go:35–46  ·  view source on GitHub ↗

extractTemplateVariables extracts template variables from a URL string e.g., "http://{host}:{port}/mcp" returns ["host", "port"]

(url string)

Source from the content-addressed store, hash-verified

33// extractTemplateVariables extracts template variables from a URL string
34// e.g., "http://{host}:{port}/mcp" returns ["host", "port"]
35func extractTemplateVariables(url string) []string {
36 re := regexp.MustCompile(`\{([^}]+)\}`)
37 matches := re.FindAllStringSubmatch(url, -1)
38
39 var variables []string
40 for _, match := range matches {
41 if len(match) > 1 {
42 variables = append(variables, match[1])
43 }
44 }
45 return variables
46}
47
48// replaceTemplateVariables replaces template variables with placeholder values for URL validation
49func replaceTemplateVariables(rawURL string) string {

Callers 3

validatePackageTransportFunction · 0.85
validateRemoteTransportFunction · 0.85
IsValidTemplatedURLFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…