Skip to content

Commit d21f77c

Browse files
committed
mcp/server: remove initialcapability struct
1 parent 21fd08b commit d21f77c

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

mcp/server.go

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
5850
type 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

mcp/server_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,9 @@ func TestServerCapabilities(t *testing.T) {
337337
name: "With initial capabilities",
338338
configureServer: func(s *Server) {},
339339
serverOpts: ServerOptions{
340-
InitialCapabilities: InitialCapabilities{
341-
Prompts: true,
342-
Tools: true,
343-
Resources: true,
344-
},
340+
HasPrompts: true,
341+
HasResources: true,
342+
HasTools: true,
345343
},
346344
wantCapabilities: &serverCapabilities{
347345
Completions: &completionCapabilities{},

0 commit comments

Comments
 (0)