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)
| 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 (.) |
| 25 | func 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 |
| 37 | func loadSchemaByVersion(version string) ([]byte, error) { |
no outgoing calls
no test coverage detected
searching dependent graphs…