Skip to content

Commit daa8608

Browse files
committed
update prm scopes and methods
1 parent 02fc77f commit daa8608

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

internal/server/mcp.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,29 +681,40 @@ func processMcpMessage(ctx context.Context, body []byte, s *Server, protocolVers
681681
}
682682

683683
type prmResponse struct {
684-
Resource string `json:"resource"`
685-
AuthorizationServers []string `json:"authorization_servers"`
684+
Resource string `json:"resource"`
685+
AuthorizationServers []string `json:"authorization_servers"`
686+
ScopesSupported []string `json:"scopes_supported,omitempty"`
687+
BearerMethodsSupported []string `json:"bearer_methods_supported"`
686688
}
687689

688690
// prmHandler generates the Protected Resource Metadata (PRM) file for MCP Authorization.
689691
func prmHandler(s *Server, w http.ResponseWriter, r *http.Request) {
690692
var servers []string
693+
var scopes []string
691694
for _, authSvc := range s.ResourceMgr.GetAuthServiceMap() {
692695
cfg := authSvc.ToConfig()
693696
if genCfg, ok := cfg.(generic.Config); ok {
694697
if genCfg.McpEnabled {
695698
servers = append(servers, genCfg.AuthURL)
699+
if genCfg.ScopesRequired != nil {
700+
scopes = genCfg.ScopesRequired
701+
}
696702
}
697703
}
698704
}
699705

700706
if servers == nil {
701707
servers = []string{}
702708
}
709+
if scopes == nil {
710+
scopes = []string{}
711+
}
703712

704713
res := prmResponse{
705-
Resource: s.toolboxUrl,
706-
AuthorizationServers: servers,
714+
Resource: s.toolboxUrl,
715+
AuthorizationServers: servers,
716+
ScopesSupported: scopes,
717+
BearerMethodsSupported: []string{"header"},
707718
}
708719

709720
w.Header().Set("Content-Type", "application/json")

internal/server/mcp_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,8 @@ func TestPRMEndpoint(t *testing.T) {
12391239
"authorization_servers": []any{
12401240
"https://example.com/oauth",
12411241
},
1242+
"scopes_supported": []any{"read", "write"},
1243+
"bearer_methods_supported": []any{"header"},
12421244
}
12431245

12441246
if !reflect.DeepEqual(got, want) {

0 commit comments

Comments
 (0)