If the number of files is not too large, you could use globbing to set the positional parameters to each matching filename, then echo back the count:
count=$(ssh [email protected] 'set -- /files/base/incomming/*.txt; echo "$#"')
Or, if the number of files is large (but less than uintmax_t), and you have GNU find (for the -printf extension), then you could use a trick I saw from Stéphane:
count=$(ssh [email protected] 'find /files/base/incomming -maxdepth 1 -type f -name '*.txt' -printf . | wc -c')
The above runs the find command against the given directory, limiting the depth to just that directory, and also limiting the matches to being plain files (-type f) and also whose name ends with .txt; for every match, a single period is printed, the total number of which is counted up by wc -c and returned from the command substitution into the assignment to count.
sftpdoesn't fork a shell on the other end, so you can't use the usual binaries. But if you can usesftpcan you also usessh?