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:
@@ -4,8 +4,11 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var ErrToolNotFound = errors.New("tool not found")
|
||||
|
||||
type ToolDescriptor struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
@@ -36,7 +39,7 @@ func (r *Registry) Tools() []ToolDescriptor {
|
||||
func (r *Registry) Dispatch(ctx context.Context, name string, args json.RawMessage) (json.RawMessage, error) {
|
||||
t, ok := r.tools[name]
|
||||
if !ok {
|
||||
return nil, errors.New("tool not found: " + name)
|
||||
return nil, fmt.Errorf("tool %q: %w", name, ErrToolNotFound)
|
||||
}
|
||||
return t.Call(ctx, args)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user