Skip to content

Commit 087d808

Browse files
authored
Replace / with - for operation IDs (#660)
<!-- Provide a brief summary of your changes --> ## Motivation and Context <!-- Why is this change needed? What problem does it solve? --> Follow up from #658 addressing the feedback from @tadasant ## How Has This Been Tested? <!-- Have you tested this in a real application? Which scenarios were tested? --> ## Breaking Changes <!-- Will users need to update their code or configurations? --> ## 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) - [ ] 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. --> - [ ] 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 ## Additional context <!-- Add any other context, implementation notes, or design decisions --> Signed-off-by: Radoslav Dimitrov <[email protected]>
1 parent 3df83c9 commit 087d808

File tree

12 files changed

+22
-14
lines changed

12 files changed

+22
-14
lines changed

docs/guides/consuming/use-rest-api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ Integration patterns and best practices for building applications that consume M
99
**Authentication**: Not required for read-only access
1010

1111
**API Versions**:
12-
- `/v0/` - Development version with latest features (may receive additive changes)
12+
- `/v0/` - Development version with latest features (may receive breaking changes)
1313
- `/v0.1/` - Stable version (only backward-compatible changes)
1414

1515
**Recommendation**: Use `/v0.1/` for production applications requiring API stability. Both versions currently have identical functionality.
16+
We may add breaking changes _only_ to `/v0/` in the future, and we reserve the possibility of deprecating `/v0/` entirely.
1617

1718
**Core endpoints:**
1819
- **`GET /v0.1/servers`** - List all servers with pagination

internal/api/handlers/v0/auth/dns.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"net"
77
"net/http"
8+
"strings"
89

910
"github.com/danielgtaylor/huma/v2"
1011
v0 "github.com/modelcontextprotocol/registry/internal/api/handlers/v0"
@@ -55,7 +56,7 @@ func RegisterDNSEndpoint(api huma.API, pathPrefix string, cfg *config.Config) {
5556

5657
// DNS authentication endpoint
5758
huma.Register(api, huma.Operation{
58-
OperationID: "exchange-dns-token" + pathPrefix,
59+
OperationID: "exchange-dns-token" + strings.ReplaceAll(pathPrefix, "/", "-"),
5960
Method: http.MethodPost,
6061
Path: pathPrefix + "/auth/dns",
6162
Summary: "Exchange DNS signature for Registry JWT",

internal/api/handlers/v0/auth/github_at.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"net/http"
99
"regexp"
10+
"strings"
1011

1112
"github.com/danielgtaylor/huma/v2"
1213
v0 "github.com/modelcontextprotocol/registry/internal/api/handlers/v0"
@@ -48,7 +49,7 @@ func RegisterGitHubATEndpoint(api huma.API, pathPrefix string, cfg *config.Confi
4849

4950
// GitHub token exchange endpoint
5051
huma.Register(api, huma.Operation{
51-
OperationID: "exchange-github-token" + pathPrefix,
52+
OperationID: "exchange-github-token" + strings.ReplaceAll(pathPrefix, "/", "-"),
5253
Method: http.MethodPost,
5354
Path: pathPrefix + "/auth/github-at",
5455
Summary: "Exchange GitHub OAuth access token for Registry JWT",

internal/api/handlers/v0/auth/github_oidc.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"io"
1010
"math/big"
1111
"net/http"
12+
"strings"
1213

1314
"github.com/danielgtaylor/huma/v2"
1415
"github.com/golang-jwt/jwt/v5"
@@ -231,7 +232,7 @@ func RegisterGitHubOIDCEndpoint(api huma.API, pathPrefix string, cfg *config.Con
231232

232233
// GitHub OIDC token exchange endpoint
233234
huma.Register(api, huma.Operation{
234-
OperationID: "exchange-github-oidc-token" + pathPrefix,
235+
OperationID: "exchange-github-oidc-token" + strings.ReplaceAll(pathPrefix, "/", "-"),
235236
Method: http.MethodPost,
236237
Path: pathPrefix + "/auth/github-oidc",
237238
Summary: "Exchange GitHub OIDC token for Registry JWT",

internal/api/handlers/v0/auth/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func RegisterHTTPEndpoint(api huma.API, pathPrefix string, cfg *config.Config) {
113113

114114
// HTTP authentication endpoint
115115
huma.Register(api, huma.Operation{
116-
OperationID: "exchange-http-token" + pathPrefix,
116+
OperationID: "exchange-http-token" + strings.ReplaceAll(pathPrefix, "/", "-"),
117117
Method: http.MethodPost,
118118
Path: pathPrefix + "/auth/http",
119119
Summary: "Exchange HTTP signature for Registry JWT",

internal/api/handlers/v0/auth/none.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"net/http"
7+
"strings"
78

89
"github.com/danielgtaylor/huma/v2"
910
v0 "github.com/modelcontextprotocol/registry/internal/api/handlers/v0"
@@ -37,7 +38,7 @@ func RegisterNoneEndpoint(api huma.API, pathPrefix string, cfg *config.Config) {
3738

3839
// Anonymous token endpoint for development/testing only
3940
huma.Register(api, huma.Operation{
40-
OperationID: "get-anonymous-token",
41+
OperationID: "get-anonymous-token" + strings.ReplaceAll(pathPrefix, "/", "-"),
4142
Method: http.MethodPost,
4243
Path: pathPrefix + "/auth/none",
4344
Summary: "Get anonymous Registry JWT (Development/Testing Only)",

internal/api/handlers/v0/auth/oidc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func RegisterOIDCEndpoints(api huma.API, pathPrefix string, cfg *config.Config)
154154

155155
// Direct token exchange endpoint
156156
huma.Register(api, huma.Operation{
157-
OperationID: "exchange-oidc-token" + pathPrefix,
157+
OperationID: "exchange-oidc-token" + strings.ReplaceAll(pathPrefix, "/", "-"),
158158
Method: http.MethodPost,
159159
Path: pathPrefix + "/auth/oidc",
160160
Summary: "Exchange OIDC ID token for Registry JWT",

internal/api/handlers/v0/edit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func RegisterEditEndpoints(api huma.API, pathPrefix string, registry service.Reg
3131

3232
// Edit server endpoint
3333
huma.Register(api, huma.Operation{
34-
OperationID: "edit-server" + pathPrefix,
34+
OperationID: "edit-server" + strings.ReplaceAll(pathPrefix, "/", "-"),
3535
Method: http.MethodPut,
3636
Path: pathPrefix + "/servers/{serverName}/versions/{version}",
3737
Summary: "Edit MCP server",

internal/api/handlers/v0/health.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package v0
33
import (
44
"context"
55
"net/http"
6+
"strings"
67

78
"github.com/danielgtaylor/huma/v2"
89
"go.opentelemetry.io/otel/attribute"
@@ -21,7 +22,7 @@ type HealthBody struct {
2122
// RegisterHealthEndpoint registers the health check endpoint with a custom path prefix
2223
func RegisterHealthEndpoint(api huma.API, pathPrefix string, cfg *config.Config, metrics *telemetry.Metrics) {
2324
huma.Register(api, huma.Operation{
24-
OperationID: "get-health" + pathPrefix,
25+
OperationID: "get-health" + strings.ReplaceAll(pathPrefix, "/", "-"),
2526
Method: http.MethodGet,
2627
Path: pathPrefix + "/health",
2728
Summary: "Health check",

internal/api/handlers/v0/ping.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package v0
33
import (
44
"context"
55
"net/http"
6+
"strings"
67

78
"github.com/danielgtaylor/huma/v2"
89
)
@@ -15,7 +16,7 @@ type PingBody struct {
1516
// RegisterPingEndpoint registers the ping endpoint with a custom path prefix
1617
func RegisterPingEndpoint(api huma.API, pathPrefix string) {
1718
huma.Register(api, huma.Operation{
18-
OperationID: "ping" + pathPrefix,
19+
OperationID: "ping" + strings.ReplaceAll(pathPrefix, "/", "-"),
1920
Method: http.MethodGet,
2021
Path: pathPrefix + "/ping",
2122
Summary: "Ping",

0 commit comments

Comments
 (0)