Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions mcp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"iter"
"maps"
"net/url"
"os"

Check failure on line 17 in mcp/server.go

View workflow job for this annotation

GitHub Actions / race-test

"os" imported and not used

Check failure on line 17 in mcp/server.go

View workflow job for this annotation

GitHub Actions / test (1.25.0-rc.3)

"os" imported and not used

Check failure on line 17 in mcp/server.go

View workflow job for this annotation

GitHub Actions / test (1.23)

"os" imported and not used

Check failure on line 17 in mcp/server.go

View workflow job for this annotation

GitHub Actions / test (1.24)

"os" imported and not used
"path/filepath"
"reflect"
"slices"
Expand Down Expand Up @@ -345,13 +346,10 @@
func (s *Server) AddResource(r *Resource, h ResourceHandler) {
s.changeAndNotify(notificationResourceListChanged, &ResourceListChangedParams{},
func() bool {
u, err := url.Parse(r.URI)
_, err := url.Parse(r.URI)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: if _, err := ...; err != nil

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ya! Updated that

if err != nil {
panic(err) // url.Parse includes the URI in the error
}
if !u.IsAbs() {
panic(fmt.Errorf("URI %s needs a scheme", r.URI))
}
}
s.resources.add(&serverResource{r, h})
return true
})
Expand All @@ -374,14 +372,6 @@
if err != nil {
panic(fmt.Errorf("URI template %q is invalid: %w", t.URITemplate, err))
}
// Ensure the URI template has a valid scheme
u, err := url.Parse(t.URITemplate)
if err != nil {
panic(err) // url.Parse includes the URI in the error
}
if !u.IsAbs() {
panic(fmt.Errorf("URI template %q needs a scheme", t.URITemplate))
}
s.resourceTemplates.add(&serverResourceTemplate{t, h})
return true
})
Expand Down
Loading