Output new ServerID after publishing (#359)

When using `mcp-publisher publish ...`, output the new server `ID` if
publishing is successful.

## Motivation and Context

It's useful to know this during testing. It means that you don't have to
go and search for the new server ID afterwards. Once we have the
`v0/servers/{name}/{version}`, I think we could consider removing this
again.

## How Has This Been Tested?

I've been using this while I test publishing to locally running
registries.

## Breaking Changes

none

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

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [x] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [x] My code follows the repository's style guidelines
- [ ] New and existing tests pass locally
- [x] I have added appropriate error handling
- [x] I have added or updated documentation as needed
This commit is contained in:
Jim Clark 2025-09-10 06:42:55 -07:00 • committed by GitHub
commit ca3da9045b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -44,3 +44,10 @@ type Metadata struct {
NextCursor string `json:"next_cursor,omitempty"`
Count int `json:"count"`
}
func (s *ServerJSON) GetID() string {
if s.Meta != nil && s.Meta.Official != nil {
return s.Meta.Official.ID
}
return ""
}