@@ -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 )
0 commit comments