Automatic generation of the schema for server.json
Right now we manually maintain the Go structs that describe the server.json format alongside its schema. This isn’t ideal, since it’s easy for the two to drift out of sync.
A better approach would be to lean on tools that let us define everything at the Go struct level and then auto-generate the schema from there. That way, we reduce errors and keep things consistent with less effort. Let’s take advantage of that.
Yep I think this would be good. Although flagging that there is discrepancy between the server.json spec and the extra restrictions on server.json that the official registry has, which we need to handle.
If the server.json format eventually becomes used for non-registry purposes, it seems likely that the schema source of truth would be moved to the modelcontextprotocol/modelcontextprotocol repo. In which case, the source of truth would become TypeScript type definitions, and the JSON schema would be generated from those.
So, are there any thoughts about generating Go structs from the JSON schema instead of the other way around?
FWIW: it is 100% the intention for server.json to live in the spec, so I agree with @jonathanhefner
That's a good point 🙏 In that case I agree it has to be the other way around: schema -> Go objects generation and/or validation (the least) 👍