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

Function extractVersionFromSchemaURL

internal/validators/schema.go:25–34  ·  view source on GitHub ↗

extractVersionFromSchemaURL extracts the version identifier from a schema URL e.g., "https://static.modelcontextprotocol.io/schemas/2025-10-17/server.schema.json" -> "2025-10-17" e.g., "https://static.modelcontextprotocol.io/schemas/draft/server.schema.json" -> "draft" Version identifier can contain

(schemaURL string)

Source from the content-addressed store, hash-verified

23// e.g., "https://static.modelcontextprotocol.io/schemas/draft/server.schema.json" -> "draft"
24// Version identifier can contain: A-Z, a-z, 0-9, hyphen (-), underscore (_), tilde (~), and period (.)
25func extractVersionFromSchemaURL(schemaURL string) (string, error) {
26 // Pattern: /schemas/{identifier}/server.schema.json
27 // Identifier allowed characters: A-Z, a-z, 0-9, -, _, ~, .
28 re := regexp.MustCompile(`/schemas/([A-Za-z0-9_~.-]+)/server\.schema\.json`)
29 matches := re.FindStringSubmatch(schemaURL)
30 if len(matches) < 2 {
31 return "", fmt.Errorf("invalid schema URL format: %s", schemaURL)
32 }
33 return matches[1], nil
34}
35
36// loadSchemaByVersion loads a schema file from the embedded filesystem by version
37func loadSchemaByVersion(version string) ([]byte, error) {

Callers 1

validateServerJSONSchemaFunction · 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…