-
Notifications
You must be signed in to change notification settings - Fork 76
Description
Is your feature request related to a problem? Please describe.
Provide a way to customize the schema generator.
Possible customizations include:
- Setting a default
additionalProperties
schema section. - Adding a schema registry to provide manually created schemas for interfaces and structures with custom scalar types.
Currently, schemas generated for structures with interfaces cause schema-related errors on the MCP client side (e.g., inspector, cursor).
Describe the solution you'd like
infer.go
file contains public method:
func For[T any]() (*Schema, error)
Introduce a new method that accepts customization options. For example:
type CustomisationOptions struct {
additionalProperties *Schema
schemaRegistry map[reflect.Type]*Schema
}
// Used for regular 'For' method
var defaultCustomisationOptions := CustomisationOptions {falseSchema(), make(map[reflect.Type]*Schema)}
func CustomisedFor[T any](options CustomisationOptions) (*Schema, error)
Describe alternatives you've considered
Helper methods to traverse generated schema and update it
Additional context
In our project, we use genqlient to generate methods and models based on a GraphQL schema and requests. GraphQL interfaces are represented in Go as struct
types containing interface
fields.
When generating schemas from such models, we encounter schemas with objects that lack fields and include additionalProperties: {not: {}}
. This causes structuredContent
validation to fail.
Allowing customization of the additionalProperties
behavior would resolve these client-side validation errors.