Skip to content

Commit bf34fb2

Browse files
fix: return error for prompt or resource template not found
1 parent e555c54 commit bf34fb2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

server/server.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,13 @@ func (s *MCPServer) handleCompletion(
10921092
handler = arg.CompletionHandler
10931093
}
10941094
}
1095+
} else {
1096+
s.promptsMu.RUnlock()
1097+
return nil, &requestError{
1098+
id: id,
1099+
code: mcp.INVALID_PARAMS,
1100+
err: fmt.Errorf("prompt '%s' not found: %w", promptRef.Name, ErrPromptNotFound),
1101+
}
10951102
}
10961103
s.promptsMu.RUnlock()
10971104
} else if resourceRef != nil {
@@ -1100,6 +1107,13 @@ func (s *MCPServer) handleCompletion(
11001107
if h, ok := resourceTemplate.template.URITemplate.ArgumentCompletionHandlers[request.Params.Argument.Name]; ok {
11011108
handler = &h
11021109
}
1110+
} else {
1111+
s.resourcesMu.RUnlock()
1112+
return nil, &requestError{
1113+
id: id,
1114+
code: mcp.INVALID_PARAMS,
1115+
err: fmt.Errorf("resource template '%s' not found: %w", resourceRef.URI, ErrResourceNotFound),
1116+
}
11031117
}
11041118
s.resourcesMu.RUnlock()
11051119
}

0 commit comments

Comments
 (0)