Skip to content

Conversation

rdimitrov
Copy link
Contributor

@rdimitrov rdimitrov commented Aug 28, 2025

Motivation and Context

The following PR eliminates duplicate struct definitions by migrating the publisher tool to use canonical types from pkg/model, creating a single source of truth across the codebase. The publisher tool previously had its own copies of structs that were duplicated, ie. ServerJSON, Package, Repository, VersionDetail, EnvironmentVariable, RuntimeArgument and a few others which was not optimal

Changes in the PR:

  • Refactored the structs to single canonical types located at pkg/model
  • Refactor the implementation to use/build canonical structures directly
  • Remove all duplicate definitions (5 structs eliminated)
  • Publisher now uses model.ServerJSON, model.Package, model.Repository, etc.
  • Renamed some of the structs to better reflect their use case, i.e. ServerJSON instead of ServerDetail
  • Fixes an issue where the Remote property was missing from the previous publisher copy of the Server

Benefits:

  • Single source of truth - Schema changes in one place
  • Type safety - Compiler catches mismatches
  • Enhanced validation - Field constraints and bson tags
  • Zero breaking changes - Same CLI interface and JSON output
  • Future-proof - New canonical fields automatically available

Supersedes: #217 and #240

How Has This Been Tested?

Locally

Breaking Changes

No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Signed-off-by: Radoslav Dimitrov <[email protected]>
Signed-off-by: Radoslav Dimitrov <[email protected]>
Signed-off-by: Radoslav Dimitrov <[email protected]>
Signed-off-by: Radoslav Dimitrov <[email protected]>
Signed-off-by: Radoslav Dimitrov <[email protected]>
Signed-off-by: Radoslav Dimitrov <[email protected]>
Signed-off-by: Radoslav Dimitrov <[email protected]>
Signed-off-by: Radoslav Dimitrov <[email protected]>
Signed-off-by: Radoslav Dimitrov <[email protected]>
Signed-off-by: Radoslav Dimitrov <[email protected]>
Signed-off-by: Radoslav Dimitrov <[email protected]>
@rdimitrov
Copy link
Contributor Author

As a follow up I am thinking to generate the server.json schema out of the go struct describing it. This should make things much more consistent and easy. This way the go object would be the source of truth for everything which is also a good practice instead of keeping in sync the schema and the object manually.

@@ -0,0 +1,42 @@
package v1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have this in v0, because all our current APIs are under /v0/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, my bad, thanks for fixing it 🙏

Copy link
Member

@domdomegg domdomegg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, can figure out renaming thing later

@domdomegg domdomegg merged commit 099a2d7 into modelcontextprotocol:main Aug 28, 2025
5 checks passed
@rdimitrov rdimitrov deleted the fix-deduplicated-model branch August 28, 2025 14:16
dmartinol pushed a commit to dmartinol/registry that referenced this pull request Aug 28, 2025
…contextprotocol#318)

<!-- Provide a brief summary of your changes -->

<!-- Why is this change needed? What problem does it solve? -->

The following PR eliminates duplicate struct definitions by migrating
the publisher tool to use canonical types from pkg/model, creating a
single source of truth across the codebase. The publisher tool
previously had its own copies of structs that were duplicated, ie.
ServerJSON, Package, Repository, VersionDetail, EnvironmentVariable,
RuntimeArgument and a few others which was not optimal

**Changes in the PR:**
- Refactored the structs to single canonical types located at pkg/model
- Refactor the implementation to use/build canonical structures directly
  - Remove all duplicate definitions (5 structs eliminated)
- Publisher now uses model.ServerJSON, model.Package, model.Repository,
etc.
- Renamed some of the structs to better reflect their use case, i.e.
ServerJSON instead of ServerDetail
- Fixes an issue where the Remote property was missing from the previous
publisher copy of the Server

**Benefits:**
  - Single source of truth - Schema changes in one place
  - Type safety - Compiler catches mismatches
  - Enhanced validation - Field constraints and bson tags
  - Zero breaking changes - Same CLI interface and JSON output
  - Future-proof - New canonical fields automatically available

Supersedes: modelcontextprotocol#217 and modelcontextprotocol#240

<!-- Have you tested this in a real application? Which scenarios were
tested? -->

Locally

<!-- Will users need to update their code or configurations? -->
No

<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update

<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [ ] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [ ] My code follows the repository's style guidelines
- [ ] New and existing tests pass locally
- [ ] I have added appropriate error handling
- [ ] I have added or updated documentation as needed

<!-- Add any other context, implementation notes, or design decisions
-->

---------

Signed-off-by: Radoslav Dimitrov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants