@@ -46,14 +46,6 @@ type Server struct {
4646 resourceSubscriptions map [string ]map [* ServerSession ]bool // uri -> session -> bool
4747}
4848
49- // InitialCapabilities allows a server to advertise support for capabilities
50- // during initialization, even if no resources for that capability have been added yet.
51- type InitialCapabilities struct {
52- Prompts bool
53- Tools bool
54- Resources bool
55- }
56-
5749// ServerOptions is used to configure behavior of the server.
5850type ServerOptions struct {
5951 // Optional instructions for connected clients.
@@ -77,10 +69,15 @@ type ServerOptions struct {
7769 SubscribeHandler func (context.Context , * SubscribeParams ) error
7870 // Function called when a client session unsubscribes from a resource.
7971 UnsubscribeHandler func (context.Context , * UnsubscribeParams ) error
80- // InitialCapabilities allows a server to advertise support for capabilities
81- // at initialization, even if no specific items (like tools or prompts)
82- // have been added yet.
83- InitialCapabilities InitialCapabilities
72+ // If true, advertises the prompts capability during initialization,
73+ // even if no prompts have been registered.
74+ HasPrompts bool
75+ // If true, advertises the resources capability during initialization,
76+ // even if no resources have been registered.
77+ HasResources bool
78+ // If true, advertises the tools capability during initialization,
79+ // even if no tools have been registered.
80+ HasTools bool
8481}
8582
8683// NewServer creates a new MCP server. The resulting server has no features:
@@ -246,13 +243,13 @@ func (s *Server) capabilities() *serverCapabilities {
246243 Completions : & completionCapabilities {},
247244 Logging : & loggingCapabilities {},
248245 }
249- if s .tools .len () > 0 || s . opts . InitialCapabilities . Tools {
246+ if s .opts . HasTools || s . tools .len () > 0 {
250247 caps .Tools = & toolCapabilities {ListChanged : true }
251248 }
252- if s .prompts .len () > 0 || s . opts . InitialCapabilities . Prompts {
249+ if s .opts . HasPrompts || s . prompts .len () > 0 {
253250 caps .Prompts = & promptCapabilities {ListChanged : true }
254251 }
255- if s .resources .len () > 0 || s .resourceTemplates .len () > 0 || s . opts . InitialCapabilities . Resources {
252+ if s .opts . HasResources || s . resources .len () > 0 || s .resourceTemplates .len () > 0 {
256253 caps .Resources = & resourceCapabilities {ListChanged : true }
257254 if s .opts .SubscribeHandler != nil {
258255 caps .Resources .Subscribe = true
0 commit comments