fix(mcp): map tool-not-found to CodeNotFound via registry sentinel

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mathias Bergqvist
2026-05-04 20:59:15 +02:00
parent 93c5a6934b
commit c6c328e517
3 changed files with 33 additions and 4 deletions

View File

@@ -90,7 +90,7 @@ func (s *Server) handlePOST(w http.ResponseWriter, r *http.Request) {
out, err := s.opts.Registry.Dispatch(r.Context(), p.Name, p.Arguments)
if err != nil {
code := -32000
if errors.Is(err, ErrToolNotFound) {
if errors.Is(err, registry.ErrToolNotFound) {
code = CodeNotFound
}
writeJSON(w, http.StatusOK,
@@ -125,8 +125,6 @@ func (s *Server) handleGET(w http.ResponseWriter, r *http.Request) {
<-r.Context().Done()
}
var ErrToolNotFound = errors.New("tool not found")
func writeJSON(w http.ResponseWriter, status int, v any) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(status)