Skip to content

Commit 4a5d1f5

Browse files
findleyryasomaru
authored andcommitted
mcp: minor cleanup of some TODOs (modelcontextprotocol#332)
Do a pass through TODOs to delete or address minor TODOs.
1 parent bfb167d commit 4a5d1f5

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

mcp/client.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ func (c *Client) AddRoots(roots ...*Root) {
226226
// RemoveRoots removes the roots with the given URIs,
227227
// and notifies any connected servers if the list has changed.
228228
// It is not an error to remove a nonexistent root.
229-
// TODO: notification
230229
func (c *Client) RemoveRoots(uris ...string) {
231230
changeAndNotify(c, notificationRootsListChanged, &RootsListChangedParams{},
232231
func() bool { return c.roots.remove(uris...) })

mcp/features.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ import (
1717
// A featureSet is a collection of features of type T.
1818
// Every feature has a unique ID, and the spec never mentions
1919
// an ordering for the List calls, so what it calls a "list" is actually a set.
20-
// TODO: switch to an ordered map
20+
//
21+
// An alternative implementation would use an ordered map, but that's probably
22+
// not necessary as adds and removes are rare, and usually batched.
2123
type featureSet[T any] struct {
2224
uniqueID func(T) string
2325
features map[string]T

mcp/server.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,18 @@ type ServerOptions struct {
8989
// The first argument must not be nil.
9090
//
9191
// If non-nil, the provided options are used to configure the server.
92-
func NewServer(impl *Implementation, opts *ServerOptions) *Server {
92+
func NewServer(impl *Implementation, options *ServerOptions) *Server {
9393
if impl == nil {
9494
panic("nil Implementation")
9595
}
96-
if opts == nil {
97-
opts = new(ServerOptions)
96+
var opts ServerOptions
97+
if options != nil {
98+
opts = *options
9899
}
100+
options = nil // prevent reuse
99101
if opts.PageSize < 0 {
100102
panic(fmt.Errorf("invalid page size %d", opts.PageSize))
101103
}
102-
// TODO(jba): don't modify opts, modify Server.opts.
103104
if opts.PageSize == 0 {
104105
opts.PageSize = DefaultPageSize
105106
}
@@ -111,7 +112,7 @@ func NewServer(impl *Implementation, opts *ServerOptions) *Server {
111112
}
112113
return &Server{
113114
impl: impl,
114-
opts: *opts,
115+
opts: opts,
115116
prompts: newFeatureSet(func(p *serverPrompt) string { return p.prompt.Name }),
116117
tools: newFeatureSet(func(t *serverTool) string { return t.tool.Name }),
117118
resources: newFeatureSet(func(r *serverResource) string { return r.resource.URI }),
@@ -463,7 +464,7 @@ func fileResourceHandler(dir string) ResourceHandler {
463464
return func(ctx context.Context, req *ServerRequest[*ReadResourceParams]) (_ *ReadResourceResult, err error) {
464465
defer util.Wrapf(&err, "reading resource %s", req.Params.URI)
465466

466-
// TODO: use a memoizing API here.
467+
// TODO(#25): use a memoizing API here.
467468
rootRes, err := req.Session.ListRoots(ctx, nil)
468469
if err != nil {
469470
return nil, fmt.Errorf("listing roots: %w", err)

mcp/shared.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
// This file contains code shared between client and server, including
66
// method handler and middleware definitions.
7-
// TODO: much of this is here so that we can factor out commonalities using
8-
// generics. Perhaps it can be simplified with reflection.
7+
//
8+
// Much of this is here so that we can factor out commonalities using
9+
// generics. If this becomes unwieldy, it can perhaps be simplified with
10+
// reflection.
911

1012
package mcp
1113

mcp/streamable.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,6 @@ func (c *streamableClientConn) Write(ctx context.Context, msg jsonrpc.Message) e
11521152
}
11531153

11541154
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
1155-
// TODO: do a best effort read of the body here, and format it in the error.
11561155
resp.Body.Close()
11571156
return fmt.Errorf("broken session: %v", resp.Status)
11581157
}

0 commit comments

Comments
 (0)