Embed external $ref schemas for offline validation#86
Merged
Conversation
The `upstream-registry.schema.json` file references external schemas via `$ref` URLs (MCP server schema and skill schema). The `gojsonschema` library follows these over HTTP during validation, which fails in network-restricted environments with timeout errors. Vendor the MCP `server.schema.json` into the embedded data directory and switch `validateAgainstSchema` from the convenience `gojsonschema.Validate` to `SchemaLoader.AddSchemas` + `Compile`, preloading referenced schemas by their `$id` so all `$ref` resolution stays local. Add a CI guard test that scans all embedded schemas for external `$ref` URLs and asserts each one has a matching `$id` among the vendored schemas. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ChrisJBurns
approved these changes
Apr 13, 2026
2 tasks
rdimitrov
added a commit
to stacklok/toolhive-registry-server
that referenced
this pull request
Apr 14, 2026
## Summary - Bump `toolhive-core` from v0.0.15 to v0.0.16 - Picks up stacklok/toolhive-core#86 which embeds all externally-referenced JSON schemas so `$ref` resolution during validation never makes HTTP requests This fixes the sync timeout reported by Peder in network-restricted environments where egress to `raw.githubusercontent.com` and `static.modelcontextprotocol.io` is blocked by network policy. ## Test plan - [x] `task all` passes (lint, tests, build) - [ ] Deploy to a network-restricted environment and verify sync completes without schema fetch timeouts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
server.schema.jsonintoregistry/types/data/so all$refresolution in JSON schema validation stays localvalidateAgainstSchemafromgojsonschema.Validate()toSchemaLoader.AddSchemas()+Compile(), preloading referenced schemas by their$idTestExternalRefsHaveEmbeddedSchemasCI guard that fails if any embedded schema has an external$refwithout a matching vendored$idProblem:
upstream-registry.schema.jsoncontains$refURLs pointing tostatic.modelcontextprotocol.ioandraw.githubusercontent.com. Thegojsonschemalibrary follows these over HTTP during validation, causing timeout failures in network-restricted deployments (e.g. environments with egress network policies).Fix: All referenced schemas are now embedded and preloaded into the
SchemaLoader, so validation never makes HTTP requests. The CI test ensures this invariant holds as schemas evolve.Test plan
TestUpstreamRegistrySchemaVersionSyncpasses (schema version alignment)TestExternalRefsHaveEmbeddedSchemaspasses (all external$refURLs resolve locally)tasksuite passes (lint + all tests)🤖 Generated with Claude Code