Fix: resolve complex OpenAPI reference chains with inline definitions #8
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.
Background
FastMCP cannot resolve complex OpenApi reference chains (e.g.,
$ref→$defs→$ref) due to unreliable schema definition generation. See upstream issue: jlowin/fastmcp#1372. Related to #7.Previously, complex
$refsonly appeared in output schemas (which we hide), so unresolved references weren't visible. Our customizer stripped$defsfrom tool schemas since they seemed unused.However, the new PointInTimeMetrics tool has complex
$refsin its input schema. With$defsstripped but references remaining, this causes "PointerToNowhere" errors since schema references can't resolve.cortex-mcp is using a legacy OpenApi parser which will be deprecated. Supposedly the new parser will fix this issue but switching broke all existing tool registration in our setup (it will become the default though, so we will need figure that out eventually).
Solution
This PR adds
openapi_resolver.pythat recursively resolves all$refchains by replacing them with inline schema definitions before FastMCP processing. This eliminates the need for$defsentirely and we can continue to drop it from the MCP tool schemas.Result